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.
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..
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.
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.
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.
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.
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.....
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.
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);
};
}
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>