Go Back   CodingForums.com > :: Client side development > Flash & ActionScript

Before you post, read our: Rules & Posting Guidelines

Reply
 
Thread Tools Rate Thread
Enjoy an ad free experience by logging in. Not a member yet? Register.
Old 12-17-2008, 02:02 PM   PM User | #1
Haima Rani
New to the CF scene

 
Join Date: Dec 2008
Posts: 7
Thanks: 1
Thanked 0 Times in 0 Posts
Haima Rani is an unknown quantity at this point
Question Dynamic slide show with a dynamic button

Hi all,

I am new to flash.
I want to create a slide show of images which should be dynamic i.e it should pull the images from a folder.For each image, there should be button overlapping the image.The button will redirect you to a different URL.Here also the button should pull the URL dynamically basically from any text file or XML.

Can any one sort my problem please.I dont know where to start and how to start.I find this forum and it seems that it will resolve my problem.

Please Please Please help me out!
Haima Rani is offline   Reply With Quote
Old 12-17-2008, 04:18 PM   PM User | #2
gnomeontherun
Senior Coder

 
gnomeontherun's Avatar
 
Join Date: Sep 2007
Location: Houston
Posts: 2,846
Thanks: 10
Thanked 238 Times in 229 Posts
gnomeontherun will become famous soon enoughgnomeontherun will become famous soon enough
http://www.codingforums.com/showthread.php?t=129968

I don't mind helping but first check the forum for other threads that discuss exactly what you want!
__________________
jeremy - gnomeontherun
Educated questions often get educated answers, and simple questions often get simple answers.
gnomeontherun is offline   Reply With Quote
Old 12-18-2008, 06:40 AM   PM User | #3
Haima Rani
New to the CF scene

 
Join Date: Dec 2008
Posts: 7
Thanks: 1
Thanked 0 Times in 0 Posts
Haima Rani is an unknown quantity at this point
Lightbulb Adding a dynamic button on the slide show

Thanks a lot jeremy

I visited the URL u gave. I got a lot of information and got the idea how should we start.It really nice.

Another Question:
I want to add a button on every image which is appearing as slide show.The button should be dynamic.The functionality of the button is that it should take to u to another URL.The URL should also be given dynamically.
I am totally confused.

How this can be achieved? Please help! This work is very important to be done for me.

I tried for creating but failed.No effects are seen!Below attached code for creatind dynamic button only.But it is also not working.

Code:
var imageGallery:XML = new XML();
imageGallery.ignoreWhite = true;
imageGallery.onLoad = loadimages;
function loadimages(success){
	if (success) {
		parsebutton();
	} else {
		descText.text = "Sorry the image data just didn't load.";
	}
};
imageGallery.load("buttons.xml");
function parsebutton():Void {
	if (imageGallery.firstChild.nodeName == "buttons") {
		var rootNode:XMLNode = imageGallery.firstChild;
		for (i=0; i<rootNode.childNodes.length; i++) {
			if (rootNode.childNodes[i].nodeName == "button") {
				currentGallery = rootNode.childNodes[i];
				imagesInGallery.push(currentGallery.childNodes.length);
				buttonNames.push(currentGallery.attributes.title);
				currentGalleryTitle = rootNode.childNodes[i].attributes.title;
				attachMovie("gallery section button", "galleryButton"+i, galleryMenu_mc.buttonsHolder_mc.getNextHighestDepth());

					for (j=0; j<currentGallery.childNodes.length; j++) {
					if (currentGallery.childNodes[j].nodeName == "link") {
						currentDescription = currentGallery.childNodes[j].firstChild.toString();
						
					}
				}
			}
		}
	}
	numberOfGalleries = i;
	enableButtons(numberOfGalleries);
}
function enableButtons(numberOfGalleries:Number):Void {
	for (i=0; i<numberOfGalleries; i++) {
		pressedButton = galleryMenu_mc.buttonsHolder_mc["galleryButton"+i];
		pressedButton.onRollOver = function():Void  {
			this.gotoAndStop(2);
		};
		pressedButton.onRollOut = function():Void  {
			this.gotoAndStop(1);
		};
		pressedButton.onPress = function():Void  {
			parsebutton();
		};
	}
	
}


If any one can help what are the bugs here and where I went wrong, I shall be really grateful to them.

Actually I want to create that button in the slide show of images whose code is below.



Code:
import mx.transitions.Tween;
import mx.transitions.easing.*;

pauseTime = 2000;

var current = 0; // This will be our current photo indicator

xmlImages = new XML();
xmlImages.ignoreWhite = true;
xmlImages.onLoad = loadImages;
xmlImages.load("images.xml");

function loadImages(loaded) {
	if (loaded) {
		xmlFirstChild = this.firstChild;
		imageFileName = [];
		totalImages = xmlFirstChild.childNodes[0].childNodes.length;
		for (i=0; i<totalImages; i++) {
			imageFileName[i] = xmlFirstChild.childNodes[0].childNodes[i].attributes.title;
		}
		nextImage();
	}
}
function nextImage() {
	if (loaded == filesize) {
		imageloader._alpha = 0;  // Start image clip as invisible
		imageloader.loadMovie(imageFileName[current], 1);  //Load random image from xml
		var pictureTweenIn:Tween = new Tween (imageloader,"_alpha",Normal.easeIn,0,100,1,true); // Use the Tween class to ease in the alpha from 0 to 100 over 1 seconds
		pictureTweenIn.onMotionFinished = function () { // When done fading
			_root.pause();  // Start pause() function
		}
	}
}
function pause() {
	myInterval = setInterval(pause_slideshow, pauseTime);
	function pause_slideshow() {
		clearInterval(myInterval);
		var pictureTweenOut:Tween = new Tween (imageloader,"_alpha",Normal.easeOut,100,0,1,true); // After pause, start fade out
		pictureTweenOut.onMotionFinished = function () { // Once faded out
		current++; // Move current indicator up to next image
			if (current >= totalImages) {  // Check that indicator is below list length, otherwise reset
				current = 0;
			}
			_root.nextImage();  // Call nextImage()
		}
	}
}




Also I have created a Dynamic Image gallery whose code is attached below:
Can I make that image gallery a slide show.If so, How?

Please Please Please Help me guys.I am totally new to this.I have just a week ago .And the deadline is coming nearer.

Please anyone can help.I am in deep puzzle
.

Last edited by Haima Rani; 12-18-2008 at 07:14 AM..
Haima Rani is offline   Reply With Quote
Old 12-18-2008, 06:43 AM   PM User | #4
Haima Rani
New to the CF scene

 
Join Date: Dec 2008
Posts: 7
Thanks: 1
Thanked 0 Times in 0 Posts
Haima Rani is an unknown quantity at this point
I forgot to attach code in my previous thread.
Please help!!!!!!!

Code:
var menuSpeed:Number = 6;
var menuDown:Button = menuDown_btn;
var menuUp:Button = menuUp_btn;
menuUp._alpha = 0;
menuUp.enabled = false;
var firstLook:Boolean = true;
var menuButtons:MovieClip = galleryMenu_mc.buttonsHolder_mc;
var galleryMask:MovieClip = galleryMenu_mc.galleryMask_mc;
galleryMask._height = 391;
var imagesHolder:MovieClip = imagesHolder_mc;
var descText:TextField = desc_txt;
var imagesInGallery:Array = new Array();
var galleryNames:Array = new Array();
var galleryIntros:Array = new Array();
var descriptions:Array = new Array();
var tracker:Number = new Number();
var whatIsLoading:String = new String();
var galleryBtnLeftMargin:Number = 10;
var galleryBtnUpperMargin:Number = 60;
var galleryBtnVSpace:Number = 23;
var thumbMarginX:Number = 96;
var thumbMarginY:Number = 68;
/* -------------------- Aligning and positioning imagesHolder_mc, the logo and the description text field -------------------- */
imagesHolder._x = 243;
imagesHolder._y = galleryBtnUpperMargin;
logo_mc._x = logo_mc._y=galleryBtnLeftMargin;
desc_txt._x = 243;
desc_txt._y = 400;
/* -------------------- The welcome text -------------------- */
descText.text = "Click on a gallery name on the left to load its thumbnails. Remember, you can click on a thumbnail only when all the thumbnails in a gallery have been loaded. When you click on a thumbnail to see the big image, clicking on the big image will close it and you will return to the gallery. Use the button(s) above the galleries to scroll through them.";
/* -------------------- Importing and defining the DropShadow filter -------------------- */
import flash.filters.DropShadowFilter;
var shadowEffect:DropShadowFilter = new DropShadowFilter(3, 45, 0x000000, 100, 3, 3, 1, 3);
var thumbsFilter:Array = [shadowEffect];
/* -------------------- MovieClipLoader & Listener -------------------- */
var loader:MovieClipLoader = new MovieClipLoader();
var myListener:Object = new Object();
loader.addListener(myListener);
myListener.onLoadInit = function(target:MovieClip) {
	if (whatIsLoading == "thumb") {
		currentThumbnail.percent_txt._visible = false;
		currentThumbnail.filters = thumbsFilter;
		thumbClickable();
		tracker++;
		if (tracker<howManyImages) {
			loadThumbnail();
		} else {
			enableThumbs();
		}
	} else if (whatIsLoading == "big") {
		target._alpha = 0;
		displayBigImage.percent_txt._visible = false;
		displayBigImage.filters = thumbsFilter;
		bigClickable();
		fadeIn();
	}
};
myListener.onLoadProgress = function(target:MovieClip, loaded:Number, total:Number) {
	percent = Math.floor(loaded/total*100);
	if (whatIsLoading == "thumb") {
		currentThumbnail.percent_txt._visible = true;
		currentThumbnail.percent_txt.text = percent+"%";
	} else if (whatIsLoading == "big") {
		displayBigImage.percent_txt._visible = true;
		displayBigImage.percent_txt.text = percent+"%";
	}
};
/* -------------------- loading XML -------------------- */
var imageGallery:XML = new XML();
imageGallery.ignoreWhite = true;
imageGallery.onLoad = loadimages;
function loadimages(success){
	if (success) {
		parseGalleries();
	} else {
		descText.text = "Sorry the image data just didn't load.";
	}
};
imageGallery.load("gallery/gallery.xml");
/* -------------------- parsing XML -------------------- */
function parseGalleries():Void {
	if (imageGallery.firstChild.nodeName == "galleries") {
		var rootNode:XMLNode = imageGallery.firstChild;
		for (i=0; i<rootNode.childNodes.length; i++) {
			if (rootNode.childNodes[i].nodeName == "gallery") {
				currentGallery = rootNode.childNodes[i];
				imagesInGallery.push(currentGallery.childNodes.length);
				galleryNames.push(currentGallery.attributes.title);
				galleryIntros.push(currentGallery.attributes.intro);
				currentGalleryTitle = rootNode.childNodes[i].attributes.title;
				currentGalleryButton = galleryMenu_mc.buttonsHolder_mc.attachMovie("gallery section button", "galleryButton"+i, galleryMenu_mc.buttonsHolder_mc.getNextHighestDepth());
				currentGalleryButton._x = 0;
				currentGalleryButton._y = galleryBtnVSpace*i;
				currentGalleryButton.sectionTitle_txt.text = "0"+(i+1)+" "+currentGalleryTitle.toUpperCase();
				for (j=0; j<currentGallery.childNodes.length; j++) {
					if (currentGallery.childNodes[j].nodeName == "image") {
						currentDescription = currentGallery.childNodes[j].firstChild.toString();
						descriptions.push(currentDescription);
					}
				}
			}
		}
	}
	numberOfGalleries = i;
	enableButtons(numberOfGalleries);
}
function enableButtons(numberOfGalleries:Number):Void {
	for (i=0; i<numberOfGalleries; i++) {
		pressedButton = galleryMenu_mc.buttonsHolder_mc["galleryButton"+i];
		pressedButton.onRollOver = function():Void  {
			this.gotoAndStop(2);
		};
		pressedButton.onRollOut = function():Void  {
			this.gotoAndStop(1);
		};
		pressedButton.onPress = function():Void  {
			removeMovieClip(thumbsDisplayer);
			removeMovieClip(displayBigImage);
			tracker = 0;
			thumbsDisplayer = imagesHolder.createEmptyMovieClip("thumbsDisplayer_mc", imagesHolder.getNextHighestDepth());
			clickedGallery = Number(this._name.substr(13));
			howManyImages = imagesInGallery[clickedGallery];
			whichGallery = galleryNames[clickedGallery];
			descText.text = galleryIntros[clickedGallery];
			currentRow = 0;
			currentColumn = 0;
			loadThumbnail();
		};
	}
	enableGalleryNavigation();
}
function loadThumbnail() {
	currentThumbnail = thumbsDisplayer.attachMovie("thumbnail holder", "thumbnail"+(tracker+1), thumbsDisplayer.getNextHighestDepth());
	target = currentThumbnail.thumbImage_mc;
	if ((tracker%5) == 0 && tracker != 0) {
		currentRow += 1;
	}
	if (currentColumn>3) {
		currentColumn = 0;
	} else if (tracker == 0) {
		currentColumn = 0;
	} else {
		currentColumn += 1;
	}
	currentThumbnail._x = currentColumn*thumbMarginX;
	currentThumbnail._y = currentRow*thumbMarginY;
	currentThumbnail.percent_txt._visible = true;
	thumbNumber = currentThumbnail._name.substr(9);
	thumbPath = "gallery/"+whichGallery+"/thumbs/"+thumbNumber+".jpg";
	whatIsLoading = "thumb";
	loader.loadClip(thumbPath, target);
}
function thumbClickable():Void {
	currentThumbnail.onPress = function() {
		bigNumber = this._name.substr(9);
		displayBigImage = imagesHolder.attachMovie("big image holder", "bigImage_mc", imagesHolder.getNextHighestDepth());
		target = displayBigImage.imageHolder_mc;
		bigImagePath = "gallery/"+whichGallery+"/"+bigNumber+".jpg";
		whatIsLoading = "big";
		disableThumbs();
		loader.loadClip(bigImagePath, target);
		if (clickedGallery>0) {
			var descPosition:Number = 0;
			for (i=0; i<clickedGallery; i++) {
				descPosition += imagesInGallery[i];
			}
			descPosition = descPosition+Number(bigNumber)-1;
			imageDesc = descriptions[descPosition];
		} else {
			imageDesc = descriptions[Number(bigNumber)-1];
		}
		descText.text = imageDesc;
	};
	currentThumbnail.enabled = false;
}
function disableThumbs():Void {
	for (i=0; i<howManyImages; i++) {
		thumbsDisplayer["thumbnail"+(i+1)].enabled = false;
	}
}
function enableThumbs():Void {
	for (i=0; i<howManyImages; i++) {
		thumbsDisplayer["thumbnail"+(i+1)].enabled = true;
	}
}
function bigClickable():Void {
	displayBigImage.onPress = function() {
		removeMovieClip(this);
		enableThumbs();
		descText.text = galleryIntros[clickedGallery];
	};
}
function fadeIn():Void {
	target.onEnterFrame = function():Void  {
		this._alpha += 10;
		if (this._alpha>=100) {
			delete this.onEnterFrame;
			this._alpha = 100;
		}
	};
}
function enableGalleryNavigation():Void {
	menuDown.onPress = function() {
		if (firstLook) {
			menuUp._alpha = 100;
			menuUp.enabled = true;
			firstLook = false;
		}
		var menuTop:Number = menuButtons._height-Math.abs(menuButtons._y);
		if (menuButtons._y<=0 && menuTop>=galleryMask._height) {
			var targetPos:Number = menuButtons._y-galleryMask._height;
			menuDown.enabled = false;
			menuUp.enabled = false;
			menuButtons.onEnterFrame = function():Void  {
				menuButtons._y += (targetPos-menuButtons._y)/menuSpeed;
				if (menuButtons._y<=(targetPos+0.8)) {
					menuButtons._y = Math.round(targetPos);
					delete menuButtons.onEnterFrame;
					menuDown.enabled = true;
					menuUp.enabled = true;
				}
			};
		}
	};
	menuUp.onPress = function() {
		var menuTop:Number = menuButtons._height-Math.abs(menuButtons._y);
		if (menuButtons._y<0 && menuTop>0) {
			var targetPos:Number = menuButtons._y+galleryMask._height;
			menuDown.enabled = false;
			menuUp.enabled = false;
			menuButtons.onEnterFrame = function():Void  {
				menuButtons._y += (-menuButtons._y+targetPos)/menuSpeed;
				if (menuButtons._y>=(targetPos-0.8)) {
					menuButtons._y = Math.round(targetPos);
					delete menuButtons.onEnterFrame;
					menuDown.enabled = true;
					menuUp.enabled = true;
				}
			};
		}
	};
}

Last edited by Haima Rani; 12-18-2008 at 07:15 AM..
Haima Rani is offline   Reply With Quote
Old 12-18-2008, 07:05 AM   PM User | #5
abduraooft
Supreme Master coder!

 
abduraooft's Avatar
 
Join Date: Mar 2007
Location: N/A
Posts: 14,680
Thanks: 158
Thanked 2,182 Times in 2,169 Posts
abduraooft is just really niceabduraooft is just really niceabduraooft is just really niceabduraooft is just really niceabduraooft is just really nice
Hi Haima Rani,
Please add [code][/code] tags to wrap your codes while posting here. You may edit your posts also.
__________________
Quote:
The Dream is not what you see in sleep; Dream is the thing which doesn't let you sleep. --(Dr. APJ. Abdul Kalam)
abduraooft is offline   Reply With Quote
Old 12-18-2008, 11:31 AM   PM User | #6
gnomeontherun
Senior Coder

 
gnomeontherun's Avatar
 
Join Date: Sep 2007
Location: Houston
Posts: 2,846
Thanks: 10
Thanked 238 Times in 229 Posts
gnomeontherun will become famous soon enoughgnomeontherun will become famous soon enough
What is this for exactly? And which codes are you using? You have two different cases here...I don't want to work with the wrong one.

Also I ask for patience, we are here to help but we are volunteers. We don't get paid to do this, so don't sound so frantic, we'll help as soon as we can. If you need someone to do it for you then post it in the Web Projects forum.
__________________
jeremy - gnomeontherun
Educated questions often get educated answers, and simple questions often get simple answers.
gnomeontherun is offline   Reply With Quote
Old 12-18-2008, 12:39 PM   PM User | #7
Haima Rani
New to the CF scene

 
Join Date: Dec 2008
Posts: 7
Thanks: 1
Thanked 0 Times in 0 Posts
Haima Rani is an unknown quantity at this point
Smile

Sorry for seeming frantic.
I need your help.
I am using this code:
Code:
import mx.transitions.Tween;
import mx.transitions.easing.*;

	pauseTime = 2000;
	var buttonURL:String; // URL variable that the button should use in getURL
	var imageObject:Object = new Object(); //Object to store the information of the images
	var thisBox = this; //Scope Variable defining the scope of the stage
	var imageFileName:Array = new Array(); //Initializing the array here

	var current = 0; // This will be our current photo indicator
	btn_mc._alpha = 0;
	xmlImages = new XML();
	xmlImages.ignoreWhite = true;
	xmlImages.onLoad = loadImages;
	xmlImages.load("images.xml");
	btn_mc._alpha = 100;
	function loadImages(loaded) {
	if (loaded) {
		xmlFirstChild = this.firstChild;
		imageFileName = [];
		totalImages = xmlFirstChild.childNodes[0].childNodes.length;
		for (i=0; i<totalImages; i++) {

					//Loading the info of the images into the image Object
					imageObject.image = xmlFirstChild.childNodes[0].childNodes[i].attributes.title;
					imageObject.imageURL = xmlFirstChild.childNodes[0].childNodes[i].attributes.url;					
					//Storing the Image Object in the Image array
					imageFileName[i] = imageObject;

					}
				nextImage();
			}
	}
	function nextImage() {
	if (loaded == filesize) {
	imageloader._alpha = 0; // Start image clip as invisible
	imageloader.loadMovie(imageFileName[current].image, 1); //Load random image from xml
	//Changing the URL variable when an image loads
	thisBox.buttonURL = imageFileName[current].imageURL;


	var pictureTweenIn:Tween = new Tween (imageloader,"_alpha",Normal.easeIn,0,100,1,true); // Use the Tween class to ease in the alpha from 0 to 100 over 1 seconds
	pictureTweenIn.onMotionFinished = function () {

		// When done fading
	_root.pause(); // Start pause() function
	}
	}
	}
	function pause() {
	myInterval = setInterval(pause_slideshow, pauseTime);
	function pause_slideshow() {
	clearInterval(myInterval);
	var pictureTweenOut:Tween = new Tween (imageloader,"_alpha",Normal.easeOut,100,0,1,true); // After pause, start fade out
	pictureTweenOut.onMotionFinished = function () { // Once faded out
	current++; // Move current indicator up to next image
	if (current >= totalImages) { // Check that indicator is below list length, otherwise reset
	current = 0;
	}
	_root.nextImage(); // Call nextImage()
	}
	}
	}
	
	function enableButtons(i:Number):Void {
		
		btn_mc.onRollOver = function():Void  {
			this.gotoAndStop(2);
		};
		btn_mc.onRollOut = function():Void  {
			this.gotoAndStop(1);
		};
And the XML is

Code:
<xml>
<images>
<a title = "1.jpg" url="http://www.google.com" />
<b title = "2.jpg" url="http://www.tcs.com" />
<c title = "3.jpg" url="http://www.testpage.com" />
<c title = "4.jpg" url="no URL" />
</images>
</xml>
This is the code which i am using.
I want that the button should take url from the xml and redirect to that url.

If any one can help......Plzzz
Haima Rani is offline   Reply With Quote
Old 12-18-2008, 12:51 PM   PM User | #8
gnomeontherun
Senior Coder

 
gnomeontherun's Avatar
 
Join Date: Sep 2007
Location: Houston
Posts: 2,846
Thanks: 10
Thanked 238 Times in 229 Posts
gnomeontherun will become famous soon enoughgnomeontherun will become famous soon enough
And what is this for that you need it so urgently?

I'll look at it later when I have a moment.
__________________
jeremy - gnomeontherun
Educated questions often get educated answers, and simple questions often get simple answers.
gnomeontherun is offline   Reply With Quote
Old 12-18-2008, 01:03 PM   PM User | #9
Haima Rani
New to the CF scene

 
Join Date: Dec 2008
Posts: 7
Thanks: 1
Thanked 0 Times in 0 Posts
Haima Rani is an unknown quantity at this point
Exclamation

Its very urgent for me.
My Supervisor had assigned this to me.I have to submit this tommorrow.Otherwise I will be punished.If u want then only u can help.I amnot forcing u in any way..Its your wish......I tried a lot.......As you know I am new to it.I am trying this over a week.So, its upto u.
Haima Rani is offline   Reply With Quote
Old 12-18-2008, 04:16 PM   PM User | #10
gnomeontherun
Senior Coder

 
gnomeontherun's Avatar
 
Join Date: Sep 2007
Location: Houston
Posts: 2,846
Thanks: 10
Thanked 238 Times in 229 Posts
gnomeontherun will become famous soon enoughgnomeontherun will become famous soon enough
You will be punished? Is this a boss or a slave driver? If your supervisor assigned this, then why did they have you do something that you are unfamiliar with? This sounds very unreasonable...

The biggest reason that I ask is to make sure this is not homework... I am just concerned by the frantic sound of your writing that it sounds like a student who isn't able to complete their homework on time. Not trying to accuse you, just trying to determine what level of help I should offer.

You've changed my original code to make it more complicated I believe. Its hard to test this for me since I don't have the FLA, but you should have another button handler like so.

Code:
imageloader.onRelease = function() { 
getURL(variableHere ,"_top");
}
Then you just need to index the current image url from your array.
__________________
jeremy - gnomeontherun
Educated questions often get educated answers, and simple questions often get simple answers.
gnomeontherun is offline   Reply With Quote
Users who have thanked gnomeontherun for this post:
Haima Rani (12-19-2008)
Old 12-19-2008, 05:39 AM   PM User | #11
Haima Rani
New to the CF scene

 
Join Date: Dec 2008
Posts: 7
Thanks: 1
Thanked 0 Times in 0 Posts
Haima Rani is an unknown quantity at this point
I have created a button with Mouse IN and Mouse Over events and stored in the library.The instance of the button is btn_mc.So the code will be:

Code:
btn_mc.onRelease = function() { 
	getURL(buttonURL ,"_top");
	}
then also it is not working.I think i had left something.What is that I dont know.I am attaching the FLA below, Please check it out. "What else can be done and what should not be done and where i went wrong"

Last edited by Haima Rani; 12-19-2008 at 07:18 AM.. Reason: I am not able to attach FLA, showing invalid file.....
Haima Rani is offline   Reply With Quote
Old 12-19-2008, 07:43 AM   PM User | #12
gnomeontherun
Senior Coder

 
gnomeontherun's Avatar
 
Join Date: Sep 2007
Location: Houston
Posts: 2,846
Thanks: 10
Thanked 238 Times in 229 Posts
gnomeontherun will become famous soon enoughgnomeontherun will become famous soon enough
Change your loadImages function so that the image url and image title are stored in two arrays not in an object. Then you can access it easily by using the image url array and the current variable which will index the proper link.
__________________
jeremy - gnomeontherun
Educated questions often get educated answers, and simple questions often get simple answers.
gnomeontherun is offline   Reply With Quote
Old 12-19-2008, 08:14 AM   PM User | #13
Haima Rani
New to the CF scene

 
Join Date: Dec 2008
Posts: 7
Thanks: 1
Thanked 0 Times in 0 Posts
Haima Rani is an unknown quantity at this point
I have change something.Have a look at it.It is now throwing error.Also the slide show is not working properly.Showing same image everytime.

Code:
import mx.transitions.Tween;
import mx.transitions.easing.*;

	pauseTime = 2000;
	var buttonURL:String; // URL variable that the button should use in getURL
	var imageObject:Object = new Object(); //Object to store the information of the images
	var thisBox = this; //Scope Variable defining the scope of the stage
	var imageFileName:Array = new Array(); //Initializing the array here
	var imageURLName:Array = new Array();



	var current = 0; // This will be our current photo indicator
	btn_mc._alpha = 0;
	xmlImages = new XML();
	xmlImages.ignoreWhite = true;
	xmlImages.onLoad = loadImages;
	xmlImages.load("images.xml");
	btn_mc._alpha = 100;
	function loadImages(loaded) {
	if (loaded) {
		xmlFirstChild = this.firstChild;
		totalImages = xmlFirstChild.childNodes[0].childNodes.length;
		for (i=0; i<totalImages; i++) {

					//Loading the info of the images into the image Object
					imageFileName[i].image = xmlFirstChild.childNodes[0].childNodes[i].attributes.title;
					imageURLName[i].imageURL = xmlFirstChild.childNodes[0].childNodes[i].attributes.url;					
					//Storing the Image Object in the Image array
					//imageFileName[i] = imageObject;

					}
				nextImage();
			}
	}
	function nextImage() {
	if (loaded == filesize) {
	imageloader._alpha = 0; // Start image clip as invisible
	imageloader.loadMovie(imageFileName[current].image, 1); //Load random image from xml
	//Changing the URL variable when an image loads
	thisBox.buttonURL = imageURLName[current].imageURL;


	var pictureTweenIn:Tween = new Tween (imageloader,"_alpha",Normal.easeIn,0,100,1,true); // Use the Tween class to ease in the alpha from 0 to 100 over 1 seconds
	pictureTweenIn.onMotionFinished = function () {

		// When done fading
	_root.pause(); // Start pause() function
	}
	}
	}
	function pause() {
	myInterval = setInterval(pause_slideshow, pauseTime);
	function pause_slideshow() {
	clearInterval(myInterval);
	var pictureTweenOut:Tween = new Tween (imageloader,"_alpha",Normal.easeOut,100,0,1,true); // After pause, start fade out
	pictureTweenOut.onMotionFinished = function () { // Once faded out
	current++; // Move current indicator up to next image
	if (current >= totalImages) { // Check that indicator is below list length, otherwise reset
	current = 0;
	}
	_root.nextImage(); // Call nextImage()
	}
	}
	}
	btn_mc.onRelease = function() {
		var mc:MovieClip =btn_mc.attachMovie("gallery section button","gallery button" +i,btn_mc.getNextHighestDepth())
		//getURL(buttonURL ,"_top");
	this.mc
	}
	
	function enableButtons(i:Number):Void {
		
		btn_mc.onPress = function():Void  {
			this.gotoAndStop(2);
		};
		btn_mc.onRelease = function():Void  {
			this.gotoAndStop(1);
		};
	

	}
Haima Rani is offline   Reply With Quote
Old 06-22-2010, 06:42 AM   PM User | #14
Graphix
New to the CF scene

 
Join Date: Jun 2010
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
Graphix is an unknown quantity at this point
Smile Assistance Needed

Hi, Ive been wrestling with this dynamic slideshow with dynamic url for 2 days now, and I cant seem to solve the last piece of the puzzle. I'm not great with code, but recogonise some of the AS language enough. I have everything down but when the FLA is exported my url link keeps duplicating in the string.
For example i have 5 images rotaing with different urls. After the swf is clicked the url is fired in my browser and comes up
http://www.domain.com/x,http://www.d...w.domain.com/s

(so not a functional page)

No matter what what image I click the url string is in the same sequence. I'm assuming its coming from my xml file which I can post at the bottom.
I have tried adding the array for the url, adding the button handler, even tweaking the child values and xml file cant alot. Can someone have a look and advise what final tweak I need to make sure one url is targeted and not 5. I can get the local target location to come up with c/document....undefined


Code:
 import mx.transitions.Tween;
import mx.transitions.easing.*;

pauseTime = 4000;

xmlImages = new XML();
xmlImages.ignoreWhite = true;
xmlImages.onLoad = loadImages;
xmlImages.load("images.xml");
    
	var imageURL:String; // URL variable that the button should use in getURL
	var imageObject:Object = new Object(); //Object to store the information of the images
	var thisBox = this; //Scope Variable defining the scope of the stage
	var imageFileName:Array = new Array(); //Initializing the array here
	var imageUrl:Array = new Array();

	var current = 0; // This will be our current photo indicator
	btn_mc._alpha = 0;


function loadImages(loaded) {
	if (loaded) {
		xmlFirstChild = this.firstChild;
		imageFileName = [];
		imageUrl = [];
		totalImages = xmlFirstChild.childNodes[0].childNodes.length;
		for (i=0; i<totalImages; i++) {
			imageFileName[i] = xmlFirstChild.childNodes[0].childNodes[i].attributes.title;
			imageUrl[i] = xmlFirstChild.childNodes[0].childNodes[i].attributes.url;
		}
		randomImage();
	}
}
function randomImage() {
	if (loaded == filesize) {
		var ran = Math.round(Math.random() * (totalImages - 1));
		picture_mc._alpha = 0;  // Start image clip as invisible
		picture_mc.loadMovie(imageFileName[ran], 1);  //Load random image from xml
		thisBox.buttonURL = imageUrl[ran];
        var pictureTweenIn:Object = new Tween (picture_mc,"_alpha",Normal.easeIn,0,100,1,true); // Use the Tween class to ease in the alpha from 0 to 100 over 1 seconds
		pictureTweenIn.onMotionFinished = function () { // When done fading
			_root.pause();  // Start pause() function
		}
	}
}
function pause() {
	myInterval = setInterval(pause_slideshow, pauseTime);
	function pause_slideshow() {
		picture_mc.onRelease=function(){
           getURL(imagesUrl[ran], "_blank");
		   currentURL = imageUrl[ran];
        } 
		clearInterval(myInterval);
		var pictureTweenOut:Object = new Tween (picture_mc,"_alpha",Normal.easeOut,100,0,1,true); // After pause, start fade out
		pictureTweenOut.onMotionFinished = function () { // Once faded out
			_root.randomImage();  // Call next randomImage()
		}
	}
}
XML
Code:
<xml>
<images>
<img title = "pic1.jpg" url = "http://www.domain.com/x" />
<img title = "pic2.jpg" url = "http://www.domain.com/y" />
<img title = "pic3.jpg" url = "http://www.domain.com/z""/>
<img title = "pic4.jpg" url = "http://www.domain.com/p"/>
<img title = "pic5.jpg" url = "http://www.domain.com/s"/>
</images>
</xml>
button handler
Code:
btn_mc.onRelease = function() { 
	getURL(imageUrl, "_blank");
	}
I would be very greatful if someone could steer me in the right direction. Thanks
Graphix is offline   Reply With Quote
Reply

Bookmarks

Jump To Top of Thread


Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +1. The time now is 03:54 AM.


Advertisement
Log in to turn off these ads.