Random Movie Slideshow - So Close But Yet So Far...
Hi,
I have a library of about 70 movie clips of company logos that fade in and fade out...I wanted to make a sort of 'random slideshow' of all the move clips, so I went ahead and copied the actionscript code for a timer that would (ideally) delay the time that it takes for the next clip to load.
Problem is, the timer starts up first thing rather than after a clip has played, and the clips then play at the same time.
The actionscript is on frame one of the Flash movie (there are about 70 clips, for the example I'm working on I'm just using 3 to start with):
stop(); function wait() { for (i=25; i<=27 { _root.attachMovie("my"+i+"_clip","new"+i+"clip", i); clearInterval(myTimer); i++; } }
myTimer = setInterval(wait, 4000);
Are there any suggestions?
KirupaForum > Flash > ActionScript 1.0/2.0
Posted on: 02-02-2005, 01:24 PM
View Complete Forum Thread with Replies
See Related Forum Messages: Follow the Links Below to View Complete Thread
Random Movie Slideshow - So Close But Yet So Far...
Hi,
I have a library of about 70 movie clips of company logos that fade in and fade out...I wanted to make a sort of 'random slideshow' of all the move clips, so I went ahead and copied the actionscript code for a timer that would (ideally) delay the time that it takes for the next clip to load.
Problem is, the timer starts up first thing rather than after a clip has played, and the clips then play at the same time.
The actionscript is on frame one of the Flash movie (there are about 70 clips, for the example I'm working on I'm just using 3 to start with):
stop();
function wait() {
for (i=25; i<=27 {
_root.attachMovie("my"+i+"_clip","new"+i+"clip", i);
clearInterval(myTimer);
i++;
}
}
myTimer = setInterval(wait, 4000);
Are there any suggestions?
Close Button In Movie To Close Swf
Can you make a button in your movie that is able to close the file. Just like if you d-click on a swf file on your desktop and it opens and plays, the flash player has an X button to close the movie. Well can you make one within the movie to do the same ?
Random Open/close Sequences
I have a site that's split into 7 sections.
Each section has its own opening and closing sequence.
So, when button 1 is clicked, it needs to run the closing sequence of whichever section is currently open, and then run the opening sequence of section 1.
And then if button 3 (eg) is clicked, it needs to check which section is open, run that section's closing sequence and then run the opening sequence of section 1. Etc.
I have absolutely no idea how to go about this; I'm really stuck. Any ideas?
Random Slideshow
Hey everyone, i am trying to complete a project and the client requested a "random" behavior from the movie, and though i know in my head how i could do it, i have no idea how to translate this to AScript. if anybody can help, it would be awesome.
The main thing I need to do is:
A set of 8 movie clips, on a slideshow sequence. (1,2,3,4...8)
Slideshow will play automatically when the page is loaded.
Slideshow would select a random MC everytime the page is loaded.
All the MCs will be transitioning into each other on the main timeline.
Any ideas on how I could do this?
Random XML Slideshow
It's that time again - I pretend I know what I'm doing when it comes to Actionscript.
Here's a mod to the MM XML slideshow that Mediachrome on were-here came up with:
stop();
slides_xml = new XML();
slides_xml.onLoad = startSlideShow;
slides_xml.load("slides.xml");
slides_xml.ignoreWhite = true;
//
// Show the first slide and intialize variables
function startSlideShow(success) {
if (success == true) {
rootNode = slides_xml.firstChild;
totalSlides = rootNode.childNodes.length;
firstSlideNode = rootNode.firstChild;
currentSlideNode = firstSlideNode;
currentIndex = 1;
updateSlide(firstSlideNode);
}
}
//
// Updates the current slide with new image and text
function updateSlide(newSlideNode) {
imagePath = newSlideNode.attributes.jpegURL;
slideText = newSlideNode.firstChild.nodeValue;
loadMovie(imagePath, targetClip);
}
//
//AutoPlay code
myImg = setInterval(test, 5*1000);
function test() {
if (currentIndex>=totalSlides or nextSlideNode == totalSlides+1) {
currentIndex = 1;
firstSlideNode = rootNode.firstChild;
currentSlideNode = firstSlideNode;
updateSlide(firstSlideNode);
} else {
nextSlideNode = currentSlideNode.nextSibling;
currentIndex++;
updateSlide(nextSlideNode);
currentSlideNode = nextSlideNode;
}
}
Can anyone help me to add a fade effect between each image? Please bear in mind I'm a designer and am more at home with pretty colours and interesting typography.
For some extra points I'd be for ever indebted to the person who could tell me how bring the slides out in a random order. That would blow my mind! I know I need to use Math.random but I don't know how to apply it.
Thanks all.
Random Slideshow
I've gone through the forum over and over again to find a solution to my problem.. and I've come up unlucky. Unless I've overlooked something, in which case I still need help.
I used the tutorial for Photo Gallery Using XML and Flash on the site. I originally used the code for the slideshow, but the need for back, forward, and pause buttons was called for. Then, I needed the slideshow to load the first image randomly from the XML file, which it does. However, I'd like to code it so that it continues in a non-random order from the current picture it is on. Say, if it randomly loads the 8th image in a set of 20, I want the slideshow to continue to image 9 in the xml file, so on and so forth. Is this possible?
Here is my actionscript:
Code:
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;
}
randomImage();
} else {
content = "file not loaded!";
}
}
xmlData = new XML();
xmlData.ignoreWhite = true;
xmlData.onLoad = loadXML;
xmlData.load("images.xml");
controls.play_btn._visible = 0;
p = 0;
delay = 7000;
controls.pause_btn.onRelease = function() {
clearInterval(myInterval);
controls.pause_btn._visible = 0;
controls.play_btn._visible = 100;
};
controls.play_btn.onRelease = function() {
myInterval = setInterval(pause_slideshow, delay);
controls.pause_btn._visible = 100;
controls.play_btn._visible = 0;
};
controls.previous_btn.onRelease = function() {
if (p == 0) {
p = total;
lastImage();
}else{
prevImage();
}
if (p == (total-1)) {
prevImage();
}
};
controls.next_btn.onRelease = function() {
//nextImage();
if (p == (total-1)) {
p = 0;
firstImage();
} else {
nextImage();
}
};
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() {
controls.pause_btn._visible = 100;
controls.play_btn._visible = 0;
if (p<(total-1)) {
p++;
if (loaded == filesize) {
clearInterval(myInterval);
picture._alpha = 0;
picture.loadMovie(image[p], 1);
slideshow();
}
}
}
function prevImage() {
controls.pause_btn._visible = 100;
controls.play_btn._visible = 0;
if (p>0) {
p--;
clearInterval(myInterval);
picture._alpha = 0;
picture.loadMovie(image[p], 1);
}
}
function firstImage() {
if (loaded == filesize) {
picture._alpha = 0;
picture.loadMovie(image[0], 1);
slideshow();
}
}
function lastImage() {
if (loaded == filesize) {
picture._alpha = 0;
picture.loadMovie(image[total-1], 1);
slideshow();
}
}
function randomImage() {
if (loaded == filesize) {
picture._alpha = 0;
picture.loadMovie(image[random(total)], 1);
}
slideshow();
}
function slideshow() {
myInterval = setInterval(pause_slideshow, delay);
}
function pause_slideshow() {
clearInterval(myInterval);
if (p == (total-1)) {
p = 0;
firstImage();
} else {
nextImage();
}
}
Random XML Slideshow
It's that time again - I pretend I know what I'm doing when it comes to Actionscript.
Here's a mod to the MM XML slideshow that Mediachrome on were-here came up with:
stop();
slides_xml = new XML();
slides_xml.onLoad = startSlideShow;
slides_xml.load("slides.xml");
slides_xml.ignoreWhite = true;
//
// Show the first slide and intialize variables
function startSlideShow(success) {
if (success == true) {
rootNode = slides_xml.firstChild;
totalSlides = rootNode.childNodes.length;
firstSlideNode = rootNode.firstChild;
currentSlideNode = firstSlideNode;
currentIndex = 1;
updateSlide(firstSlideNode);
}
}
//
// Updates the current slide with new image and text
function updateSlide(newSlideNode) {
imagePath = newSlideNode.attributes.jpegURL;
slideText = newSlideNode.firstChild.nodeValue;
loadMovie(imagePath, targetClip);
}
//
//AutoPlay code
myImg = setInterval(test, 5*1000);
function test() {
if (currentIndex>=totalSlides or nextSlideNode == totalSlides+1) {
currentIndex = 1;
firstSlideNode = rootNode.firstChild;
currentSlideNode = firstSlideNode;
updateSlide(firstSlideNode);
} else {
nextSlideNode = currentSlideNode.nextSibling;
currentIndex++;
updateSlide(nextSlideNode);
currentSlideNode = nextSlideNode;
}
}
Can anyone help me to add a fade effect between each image? Please bear in mind I'm a designer and am more at home with pretty colours and interesting typography.
For some extra points I'd be for ever indebted to the person who could tell me how bring the slides out in a random order. That would blow my mind! I know I need to use Math.random but I don't know how to apply it.
Thanks all.
Random Slideshow
I used the tutorial for Photo Gallery Using XML and Flash on the Kirupa website. I originally used the code for the slideshow, but the need for back, forward, and pause buttons was called for. Then, I needed the slideshow to load the first image randomly from the XML file, which it does. However, I'd like to code it so that it continues in a non-random order from the current picture it is on. Say, if it randomly loads the 8th image in a set of 20, I want the slideshow to continue to image 9 in the xml file, so on and so forth. Is this possible?
Here is my actionscript:
Code:
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;
}
randomImage();
} else {
content = "file not loaded!";
}
}
xmlData = new XML();
xmlData.ignoreWhite = true;
xmlData.onLoad = loadXML;
xmlData.load("images.xml");
controls.play_btn._visible = 0;
p = 0;
delay = 7000;
controls.pause_btn.onRelease = function() {
clearInterval(myInterval);
controls.pause_btn._visible = 0;
controls.play_btn._visible = 100;
};
controls.play_btn.onRelease = function() {
myInterval = setInterval(pause_slideshow, delay);
controls.pause_btn._visible = 100;
controls.play_btn._visible = 0;
};
controls.previous_btn.onRelease = function() {
if (p == 0) {
p = total;
lastImage();
}else{
prevImage();
}
if (p == (total-1)) {
prevImage();
}
};
controls.next_btn.onRelease = function() {
//nextImage();
if (p == (total-1)) {
p = 0;
firstImage();
} else {
nextImage();
}
};
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() {
controls.pause_btn._visible = 100;
controls.play_btn._visible = 0;
if (p<(total-1)) {
p++;
if (loaded == filesize) {
clearInterval(myInterval);
picture._alpha = 0;
picture.loadMovie(image[p], 1);
slideshow();
}
}
}
function prevImage() {
controls.pause_btn._visible = 100;
controls.play_btn._visible = 0;
if (p>0) {
p--;
clearInterval(myInterval);
picture._alpha = 0;
picture.loadMovie(image[p], 1);
}
}
function firstImage() {
if (loaded == filesize) {
picture._alpha = 0;
picture.loadMovie(image[0], 1);
slideshow();
}
}
function lastImage() {
if (loaded == filesize) {
picture._alpha = 0;
picture.loadMovie(image[total-1], 1);
slideshow();
}
}
function randomImage() {
if (loaded == filesize) {
picture._alpha = 0;
picture.loadMovie(image[random(total)], 1);
}
slideshow();
}
function slideshow() {
myInterval = setInterval(pause_slideshow, delay);
}
function pause_slideshow() {
clearInterval(myInterval);
if (p == (total-1)) {
p = 0;
firstImage();
} else {
nextImage();
}
}
Random Images Slideshow
i used the flash mx samples file for a pictures slideshow...it works based on 2 buttons (back and fwd)...and on a text field you can type the number of the picture you want to see.
what i want to do is an automatic slideshow...from the beginning to the end going through all the pics...
the pics are loaded from a folder...they are not in the flash file library
Random Loading SlideShow
I'm creating a movie with a randomly loading slide show. The movie has 4 sets of 5 slides each that will randomly load everytime the page refreshs or that the site is revisited.
I am also tring to insert a menu on top of that slide show..
Does anyone know how this would be accomplished?
Random Slideshow - No Repeats
Hi People,
I am new to actionscript, but I am fast realising I need to do some serious study to get the hang of all this! I found this slideshow source at www.whatdoiknow.org, and it works perfectly, except that when the slides are set in random (not sequential) they repeat one or two before all the images in the array are shown. Is it possible to make it so that all the images are shown once before there are any repeats?
I would be very grateful for any help you guys can offer! I have attached the fla.
Here is the code:
code:
// **************************
// Crossfading slide show
// Author: Todd Dominey
// http://whatdoiknow.org
// http://domineydesign.com
// **************************
// set random # variables - each must be 0 for first 'while' loop below
var randomNum = 0;
var randomNumLast = 0;
// parent container
var container_mc = this.createEmptyMovieClip("container", 0);
// movie clip containers
container_mc.createEmptyMovieClip("loader1_mc", 2);
container_mc.createEmptyMovieClip("loader2_mc", 1);
// preload watcher
this.createEmptyMovieClip("watcher_mc", 100);
// load xml
images_xml = new XML();
images_xml.ignoreWhite = true;
images_xml.onLoad = parse;
images_xml.load("images.xml");
function parse(success) {
if (success) {
imageArray = new Array();
var root = this.firstChild;
_global.numPause = Number(this.firstChild.attributes.timer*1000);
_global.order = this.firstChild.attributes.order;
_global.looping = this.firstChild.attributes.looping;
_global.fadetime = Number(this.firstChild.attributes.fadetime);
_global.xpos = Number(this.firstChild.attributes.xpos);
_global.ypos = Number(this.firstChild.attributes.ypos);
var imageNode = root.lastChild;
var s = 0;
while (imageNode.nodeName != null) {
imageData = new Object();
imageData.path = imageNode.attributes.path;
imageArray[s] = imageData;
imageNode = imageNode.previousSibling;
s++;
}
// place parent container
container_mc._x = _global.xpos;
container_mc._y = _global.ypos;
// parse array
imageArray.reverse();
imageGen(imageArray);
} else {
trace("problem");
}
}
// depth swapping
function swapPlace(clip, num) {
eval(clip).swapDepths(eval("container_mc.loader"+n um+"_mc"));
}
function loadImages(data, num) {
if (i == undefined || i == 2) {
i = 2;
createLoader(i, data, num);
i = 1;
} else if (i == 1) {
createLoader(i, data, num);
i = 2;
}
}
function createLoader(i, data, num) {
thisLoader = eval("container_mc.loader"+i+"_mc");
thisLoader._alpha = 0;
thisLoader.loadMovie(data[num].path);
watcher_mc.onEnterFrame = function() {
var picLoaded = thisLoader.getBytesLoaded();
var picBytes = thisLoader.getBytesTotal();
if (isNaN(picBytes) || picBytes<4) {
return;
}
if (picLoaded/picBytes>=1) {
swapPlace("container_mc.loader2_mc", 1);
thisLoader.alpha(_global.fadeTime, 100);
timerInterval = setInterval(imageGen, _global.numPause, data);
delete this.onEnterFrame;
}
};
}
function imageGen(data) {
// random, or sequential?
if (_global.order == "random") {
// choose random # between 0 and total number of images
while (randomNum == randomNumLast) {
randomNum = Math.floor(Math.random()*data.length);
trace(randomNum);
}
loadImages(data, randomNum);
randomNumLast = randomNum;
} else if (_global.order == "random") {
// start at 0, increment to total number of images, then drop back to zero when done
if (p == undefined || p == data.length && _global.looping == "yes") {
p = 0;
} else {
break;
}
loadImages(data, p);
p++;
} else {
trace("order attribute in xml isn't correct - must specify either 'random' or 'sequential'");
}
clearInterval(timerInterval);
}
stop();
Random Slideshow Troubles
I am using MX 2004 and having trouble with a banner. I want to randomly load .jpg's from a file - pausing for 5 sec on each pic. I can get one .jpg to load, but it stops after one. Here's is the codes:
var numArray = ["randomPics/01.jpg",
"randomPics/02.jpg",
"randomPics/03.jpg",
"randomPics/04.jpg",
"randomPics/05.jpg",
"randomPics/06.jpg",
"randomPics/07.jpg",
"randomPics/08.jpg",
"randomPics/09.jpg",
"randomPics/10.jpg"];
this.createEmptyMovieClip("clip_mc", 2);
function changePic(){
numPic = random(numArray.length);
_root.loadMovie(numArray[numPic], "clip_mc");
}
this.onEnterFrame = function(){
setInterval(changePic, 5000);
}
Random Slideshow Tutorials
does anyone know where i can find a tutorial for 'random slideshow', for flash mx 2004?
thanks in advance,
jgatienza
[F8] Script Help Random Slideshow
I am a relative newbie. I have an autoplay random image xml slideshow. The problem is, I don't want the images to repeat until all of them have been shown. I've see posts with some hints about this, something about "shuffle" but I don't know what script or where I should add or change it. Any direction would be greatly appreciated!!!!
Here's the script:
//: SETUP INITIAL VARIABLES
var oldVar = 0;// keep track of previous random number
var newVar = 0;// used to load the next image
var si = 0;// interval variable
//: GET XML
var my_xml = new XML();// create our xml object
my_xml.ignoreWhite = true;// tell object to ignore all the white space in the file
my_xml.onLoad = function (success) {// when load function is called, pass a temp variable
if (success) {// if the temp variable was passed; file was loaded
// now that the xml has loaded successfully
// lets setup our final variables
library = this.firstChild.childNodes;// get all the <jpg> nodes
maxVal = library.length;// max number of fotos
// now that we've retrieve our xml ...
delete my_xml;// delete our xml object
getImage();// load first image
} else {// if the temp variable was not passed; file was not loaded
desc_txt.text = 'Error: XML Not Loaded';// display an errorr message on your text field
}
}
my_xml.load('library.xml');
//: LOAD THE NEXT IAMGE
function getImage() {
newVar = Math.floor(Math.random() * maxVal);// get random number
if (newVar == oldVar) {// if number = old number..
getImage();// get a number
} else {// else
oldVar = newVar;// set old to new number
container_mc.loadMovie (library[newVar].firstChild.firstChild.nodeValue);// load the next image
container_mc._alpha = 0;// set its alpha to 0
this.onEnterFrame = function () {// create loop
if (container_mc._width > 0) {// check that the image has been loaded
container_mc._x = Stage.width / 2 - container_mc._width / 2;// center movieclips to stage
container_mc._y = Stage.height / 2 - container_mc._height / 2;// center movieclip to stage
container_mc.onEnterFrame = fadeIn;// start fading out
desc_txt.text = library[newVar].firstChild.nextSibling.firstChild.nodeValue;// display the images description
delete this.onEnterFrame;// delete loop
}
}
}
}
//: FADE IN THE CURRENT MOVIECLIP
function fadeIn () {
if (this._alpha <= 100) {// if the movieclips alpha is greater than 0
this._alpha += 5;// reduce alpha by 5
} else {// else
this._alpha = 100;// reduce alpha to 0
delete this.onEnterFrame;// delete handler
si = setInterval(fadeOut, 2000);// after 2 seconds, fade out the movieclip
}
}
//: FADE OUT THE CURRENT MOVIECLIP
function fadeOut () {
clearInterval(si);// clear the interval variable
container_mc.onEnterFrame = function() {// create loop to fade out
if (this._alpha >= 0) {// if the movieclips alpha is greater than 0
this._alpha -= 5;// reduce alpha by 5
} else {// else
this._alpha = 0;// reduce alpha to 0
delete this.onEnterFrame;// delete handler
getImage();// load the next image
}
}
}
Thanks again!
Random Image Slideshow
Hi, I have a project for this company that requires an image slideshow to show 46 images, with small fade cuts separating each image. The way I have set up now, is just spread out on the timeline, and a very simple movie clip. I showed it to the president today, and he wants me the images to be shown at random so that they are not at all in the same sequence every time a visitor views the main page. I've looked at several random number generators and various other randomizers, and nothing appears to be controlled by just time. I found one that works by loading a different image every time the page is refreshed, but what I am looking for is for a new image to appear through a simple fade transition every 45 frames. I know the solution might require some very redundant coding because of the number of images, but i'm willing to make the sacrifice. any help?
Random Slideshow Using Flash?
Does anybody have a code that will generate random slideshow just like apple computer screensaver but in flash? with the same kind of motion and transitioning?
XML Random Slideshow W/Captions
Hello,
How would I modify this code to add captions to the images?
ActionScript Code:
new_mc = this.createEmptyMovieClip("mc1", 1);
old_mc = this.createEmptyMovieClip("mc2", 2);
myarray = [];
//stick names of your clips here
function shuffle() {
return Math.floor(Math.random()*3)-1;
}
for (var i = 1; i<9; i++) {
myarray.push(i+".jpg");
}
trace(myarray);
myarray.sort(shuffle);
trace(myarray);
var c = 0;
function loadSwf(clip) {
clearInterval(mi);
new_mc._alpha = 0;
new_mc.swapDepths(old_mc);
new_mc.loadMovie(clip);
var ctrl = this.createEmptyMovieClip("ctrl", 3);
c++;
c %= myarray.length;
ctrl.onEnterFrame = function() {
if (new_mc._width) {
old_mc._alpha -= 5;
new_mc._alpha += 5;
if (old_mc._alpha<=0 && new_mc._alpha>=100) {
delete this.onEnterFrame;
trace(new_mc.getDepth());
var myvar = old_mc;
old_mc = new_mc;
new_mc = myvar;
mi = setInterval(startoff, 5000);
}
}
};
}
function startoff() {
//put path to folder here
loadSwf("http://www.domain.com/images/"+myarray[c]);
}
startoff();
XML Random Image Slideshow
I'm pulling my hair out trying to figure out how to make it pull the image and the text assiociated with the image randomly. Any direction would be greatly appreciated:
Attach Code
var id, current;
var k = 0, p = 0;
var slide = 1;
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;
}
id = setInterval(preloadPic, 100);
} else {
content = "file not loaded!";
}
}
xmlData = new XML();
xmlData.ignoreWhite = true;
xmlData.onLoad = loadXML;
xmlData.load("assets/flash/splash/images.xml");
function Math.preloadPic()(Math.random()*5) {
clearInterval(id);
var con = picture.duplicateMovieClip("con"+k, 200+k);
con.loadMovie(image[p]);
_root.txt.desc_text_mov.desc_txt.text = description[p];
preloader._visible = 1;
con._alpha = 0;
var temp = picture.createEmptyMovieClip("temp"+k, 99+k);
k++;
temp.onEnterFrame = function() {
var total = con.getBytesTotal();
var loaded = con.getBytesLoaded();
percent = Math.round(loaded/total*100);
preloader.preload_bar._xscale = percent;
if (con._width) {
preloader._visible = 0;
con.onEnterFrame = fadeIn;
_root.txt.gotoAndPlay(2);
if (slide) {
id = setInterval(nextImage, 9000);
}
delete this.onEnterFrame;
}
};
}
MovieClip.prototype.fadeIn = function() {
if (this._alpha<100) {
current._alpha -= 10;
this._alpha += 10;
} else {
current._visible = 0;
current = this;
delete this.onEnterFrame;
}
};
function nextImage() {
current = this["con"+p];
p<total-1 ? p++ : p=0;
preloadPic();
}
function prevImage() {
current = this["con"+p];
p>0 ? p-- : p=total-1;
preloadPic();
}
preloadPic();
Random Image Slideshow
Hi all, i've been trying to work with this actionscript to make it random and i just can't seem to do it. Any direction would be greatly appreciated.
Code:
var id, current;
var k = 0, p = 0;
var slide = 1;
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;
}
id = setInterval(preloadPic, 100);
} else {
content = "file not loaded!";
}
}
xmlData = new XML();
xmlData.ignoreWhite = true;
xmlData.onLoad = loadXML;
xmlData.load("assets/flash/splash/images.xml");
function Math.preloadPic()(Math.random()*5) {
clearInterval(id);
var con = picture.duplicateMovieClip("con"+k, 200+k);
con.loadMovie(image[p]);
_root.txt.desc_text_mov.desc_txt.text = description[p];
preloader._visible = 1;
con._alpha = 0;
var temp = picture.createEmptyMovieClip("temp"+k, 99+k);
k++;
temp.onEnterFrame = function() {
var total = con.getBytesTotal();
var loaded = con.getBytesLoaded();
percent = Math.round(loaded/total*100);
preloader.preload_bar._xscale = percent;
if (con._width) {
preloader._visible = 0;
con.onEnterFrame = fadeIn;
_root.txt.gotoAndPlay(2);
if (slide) {
id = setInterval(nextImage, 9000);
}
delete this.onEnterFrame;
}
};
}
MovieClip.prototype.fadeIn = function() {
if (this._alpha<100) {
current._alpha -= 10;
this._alpha += 10;
} else {
current._visible = 0;
current = this;
delete this.onEnterFrame;
}
};
function nextImage() {
current = this["con"+p];
p<total-1 ? p++ : p=0;
preloadPic();
}
function prevImage() {
current = this["con"+p];
p>0 ? p-- : p=total-1;
preloadPic();
}
preloadPic();
Random Slideshow Effect Help
Please help me to add an effect (fade in-out or else) on random image slideshow with code:
var picArray:Array = new Array();
picArray[0] = "images/0.jpg";
picArray[1] = "images/1.jpg";
picArray[2] = "images/2.jpg";
picArray[3] = "images/3.jpg";
picArray[4] = "images/4.jpg";
picArray[5] = "images/5.jpg";
picArray[6] = "images/6.jpg";
picArray[7] = "images/7.jpg";
picArray[8] = "images/8.jpg";
picArray[9] = "images/9.jpg";
picArray[10] = "images/10.jpg";
picArray[11] = "images/11.jpg";
picArray[12] = "images/12.jpg";
picArray[13] = "images/13.jpg";
picArray[14] = "images/14.jpg";
picArray[15] = "images/15.jpg";
picArray[16] = "images/16.jpg";
picArray[17] = "images/17.jpg";
picArray[18] = "images/18.jpg";
picArray[19] = "images/19.jpg";
picArray[20] = "images/20.jpg";
picArray[21] = "images/21.jpg";
picArray[22] = "images/22.jpg";
picArray[23] = "images/23.jpg";
var i = 0;
trace(picArray.length);
mi = setInterval(function () {
rndNum = Math.floor(Math.random()*picArray.length);
var clip = _root.attachMovie("pic", "pic"+i, i++);
loader.loadMovie(picArray[rndNum]);
trace("picArray.length= "+picArray.length+" picArray[rndNum] = "+picArray[rndNum]);
picArray.splice(rndNum, 1);
if (picArray.length == 0) {
clearInterval(mi);
}
}, 2000);
i have found something but I can't implement it to this code...
Random Slideshow, URL Problem
I've been working on this great slideshow from NoPonies and wanted to add a url link called from the xml to each images. I'm very close i'm sure but can anyone help me it's driving me crazy for two days now...
here's the as and the files are attached:
import flash.display.BitmapData;
import mx.utils.Delegate;
import gs.TweenLite;
class simpleSlideCaptions extends MovieClip {
//vars for XML
private var slideImage:XML;
public var bgImages:Array;
public var captionsArray:Array;
private var p:Number = 0;//track pos in arrays
//Variables pulled in from XML
private var crossFadeTime:Number;
private var imageTime:Number;
private var order:String;
private var captions:Boolean;
private var persistentCaptions:Boolean;
//empty mcs
public var holder_mc:MovieClip;
//set interval
private var bitmapFadeInterval:Number=0
//movieClip Loader
private var slideLoader:MovieClipLoader;
//textField Holder MC
private var captionsHolder:MovieClip;
//textField
private var captionsText:TextField;
//url
private var link:String;
//XML loc
private var xmlData:String;
//random image tracker
private var randomImg:Number;
//text array tracker
private var textInc:Number = 0
/******************************************
TEXTFIELD SPECIFIC VARS
******************************************/
//textField Padding, left and right indent from edge of image
private var captionsPadding:Number = 75;
//textField BG Colour
private var textFieldBgColour:Number = 0x000000;
//textField Bg Alpha
private var textFieldBgAlpha:Number = 100;
//textField Colour
private var textColour:Number = 0xFFFFFF;
//textField Font
private var textFieldFont:String = "PF_Ronda_Seven_Bold";//font, embedded in library, set to export for actionScript
//textField Text Size
private var textFieldFontSize:Number = 11;
//textField Use Embedded Fonts
private var textFieldUseEmbedded:Boolean = true;//use if using embedded fonts
//passed via constructor argument, is the location movieClip you want the slideshow to appear in
private var slideTarget_mc:MovieClip;
/*****************************************/
function simpleSlideCaptions(slideTargets:MovieClip, xmlData:String) {
//grab a reference to the class instance for use in the XML parsing routine
var thisObj:simpleSlideCaptions = this;
slideTarget_mc = slideTargets;
this.xmlData = xmlData;
//movieClip loader
slideLoader = new MovieClipLoader();
slideLoader.addListener(this);//give the scope of this class instance
var slideImage:XML = new XML();
slideImage.ignoreWhite = true;
slideImage.onLoad = function(success:Boolean) {
if (success) {
thisObj.slideImage = this;
//get vars from XML file
thisObj.crossFadeTime = this.firstChild.attributes.crossFadeTime;
thisObj.imageTime = this.firstChild.attributes.imageTime;
thisObj.imageTime = (1000*60)*thisObj.imageTime;
thisObj.order = String(this.firstChild.attributes.order);
thisObj.captions = Boolean(parseInt(this.firstChild.attributes.captio ns));//cast as boolean
thisObj.persistentCaptions = Boolean(parseInt(this.firstChild.attributes.persis tentCaptions));//cast as boolean
thisObj.p = 0;
thisObj.bgImages = [];//reset the array var, should for some reason you want to load in a different set of images
thisObj.captionsArray = [];
var xmlNodes = this.firstChild;
var largeImages = xmlNodes.childNodes.length;
var i = 0;
for (i=0; i<largeImages; i++) {
thisObj.bgImages[i] = xmlNodes.childNodes[i].childNodes[0].firstChild.nodeValue;
if (thisObj.captions == 1) {
thisObj.captionsArray[i] = xmlNodes.childNodes[i].childNodes[1].firstChild.nodeValue;
}
link[i] = xmlNodes.childNodes[i].childNodes[2].firstChild.nodeValue;
}
//load random image when we successfully parse XML
//note reference to class instance
thisObj.init();
} else {
trace("Fatal Error - Loading slideshow images XML failed");
}
};
//lets load the XML file
slideImage.load(xmlData);
}
//second constructor function, here we create our empty mc, set up the movieClipLoaders and finally call the loadSlides function
private function init() {
//we have xml content, so lets start the image loading.
holder_mc = slideTarget_mc.createEmptyMovieClip("holder_mc", 1);
holder_mc._x = 0;
holder_mc._y = 0;
//create the captions if we want them
if (captions) {
//create captions text text field, empty mc and background MC
captionsHolder = holder_mc.createEmptyMovieClip("captionsHolder", 3);
captionsHolder.createEmptyMovieClip("captionsHolde rBg",1);
//draw the bg mc's fill
captionsHolder.captionsHolderBg.beginFill(textFiel dBgColour,textFieldBgAlpha);//fill colour, and alpha value set here!
captionsHolder.captionsHolderBg.moveTo(0,0);
captionsHolder.captionsHolderBg.lineTo(10,0);
captionsHolder.captionsHolderBg.lineTo(10,10);
captionsHolder.captionsHolderBg.lineTo(0,10);
captionsHolder.captionsHolderBg.lineTo(0,0);
captionsHolder.captionsHolderBg.endFill();
//create the captions text field
captionsHolder.createTextField("captionsText",2,0, 0,0,0);//all zeros, we set its width etc later.
//text format
var my_fmt:TextFormat = new TextFormat();
my_fmt.font = textFieldFont;//font
my_fmt.size = textFieldFontSize;//size
my_fmt.color = textColour;//text colour
my_fmt.align = "justify";
//text field properties
captionsHolder.captionsText.embedFonts = textFieldUseEmbedded;
captionsHolder.captionsText.autoSize = "left";
captionsHolder.captionsText.wordWrap = true;
captionsHolder.captionsText.html = true;
captionsHolder.captionsText.setNewTextFormat(my_fm t);
//add mouse event listeners if we want captions and they are set to not be persistent
//be aware that links in captions text will fail to work if you turn on the rollovers.
if (!persistentCaptions) {
//use delegate to scope functions
this.holder_mc.onRollOver = Delegate.create(this, imageOverHandler);
this.holder_mc.onRollOut = Delegate.create(this, imageOffHandler);
this.holder_mc.onRelease = Delegate.create(this, imagePressHandler);
}
//set the captions to have a 0 alpha, tweened in later
captionsHolder._alpha = 0;
}
//load the slide
loadSlides();
}
//captions function. Loads, resizes and tweens in the captions text
private function imageOverHandler() {
captionsHolder.captionsText._x = holder_mc._x+captionsPadding;//place text field, we only use x, as we adjust the parent mc's y value.
captionsHolder.captionsText._width = holder_mc._width-(captionsPadding*2);//size text field with some padding
captionsHolder.captionsText.htmlText = captionsArray[textInc];//populate text field
captionsHolder.captionsHolderBg._width = holder_mc._width;//size bg clip
captionsHolder.captionsHolderBg._height = captionsHolder.captionsText._height+5;//size bg clip with some padding
captionsHolder._y = (holder_mc._y+holder_mc._height-captionsHolder.captionsHolderBg._height)-225;//bottom align text//adjust here if needed pos of text
TweenLite.to(captionsHolder,1,{_alpha:100});
}
//captions removal function, tweens text to 0 alpha and removes its content.
private function imageOffHandler() {
TweenLite.to(captionsHolder,1,{_alpha:0, onComplete:emptyText, onCompleteParams:[this]});
function emptyText(ref) {
ref.captionsHolder.captionsText.htmlText = "";
ref.captionsHolder._y = 0;//reset y of captions
}
}
private function imagePressHandler() {
getURL(link[p], "_self");
}
private function onLoadProgress(target:MovieClip, bytesLoaded:Number, bytesTotal:Number):Void {
//amountLoaded = Math.floor((bytesLoaded/bytesTotal)*100);//calulate a loading percentage!
//do something with this data if you want
}
//run when we have image data
private function onLoadInit(target:MovieClip):Void {
/*remove the captions text, if we have it enabled. Check to see if the cursor is on the image, if it is run this function.
means that we can have a situation where the captions are set to display on mouseOver, but the image swaps, leaving old captions
because the mouse has not moved off the image to retrigger the captions functions. We also just don't want to call this function
all the time either, as we would have a situation where we have enabled mouseOver captions, but they would show up, even if the mouse
was not over the image*/
if (captions && persistentCaptions || captions && holder_mc.hitTest(_root._xmouse, _root._ymouse, true)) {
imageOffHandler();
}
//clear the existing interval
clearInterval(this.bitmapFadeInterval);
//alpha out our image we load our bitmap into
target._alpha = 0;
//create the bitmap object, each time this is reset, keeping memory footprint fairly low..
var bitmap:BitmapData = new BitmapData(target._width, target._height, true);
//draw the bitmap
bitmap.draw(target);
//fade in the temp mc
TweenLite.to(target,this.crossFadeTime,{_alpha:100 , onComplete:onFinishTween, onCompleteParams:[this]});//pass reference to class
//as "this" refers to the tween object itself when called from the tween onComplete handler...
function onFinishTween(ref) {
//attach our loaded bitmap to our background mc when the temp totally obscures it
ref.holder_mc.attachBitmap(bitmap,0,"auto",true);
//fade the temp back to 0
TweenLite.to(target,.1,{_alpha:0, onComplete:clearTween});
//tween in the captions text. See above description for rationale.
if (ref.captions && ref.persistentCaptions || ref.captions && ref.holder_mc.hitTest(_root._xmouse, _root._ymouse, true)) {
ref.imageOverHandler();
}
function clearTween() {
//remove the temp mc
removeMovieClip(ref.holder_mc.bg_loader);
}
//reset the timer
//increment manual click var
ref.beginInterval();
}
}
private function beginInterval():Void {
this.bitmapFadeInterval = setInterval(this, "loadSlides", imageTime);
}
/*Load the slides.*/
private function loadSlides() {
if (order == "random") {
//create the temp loader mc that we load our new image into
holder_mc.createEmptyMovieClip("bg_loader",2);
getUniqueNum();
} else {
//sequential loading of images
holder_mc.createEmptyMovieClip("bg_loader",2);
slideLoader.loadClip(bgImages[p],holder_mc.bg_loader);
textInc = p
p++;
if (p == bgImages.length) {
p = 0;
}
}
}
//generate a unique number, no immediate duplicates in random slide shows
private function getUniqueNum() {
var tempRandomImg = Math.floor(Math.random(bgImages.length)*bgImages.l ength);
if (tempRandomImg == randomImg &&bgImages.length>1 ) {
getUniqueNum();
} else {
randomImg = p = textInc = tempRandomImg;
slideLoader.loadClip(bgImages[randomImg],holder_mc.bg_loader);
}
}
//kill the interval functions
public function killInterval() {
clearInterval(bitmapFadeInterval);
bitmapFadeInterval = null
}
}
Thanks in advance.
Random Image On Slideshow
hii
periority(High)
can anybody help me to find out the issue which coming with PNG files on slideshow the fading in & OUT IS NOT SMOOTH. WITH JPG ITS WORKING FINE
for testing just paste this code on ur 1st frame & test it,
2nd periority(low)
in this i need Random image in this Slideshow write now its coming in seqential order.
can anybody help me in that,what will be the code for that ?
or
suppose if i load these images through flashvars,can i load random image on each refresh. is it possible?
//AS-2 started
// put the image name here
photos = "1.png,2.png,3.png,4.png,5.png,6.png";
interval = "6";
_root.checkthisroot = true;
if (checkthisroot) {
Stage.scaleMode = "noScale";
Stage.align = "TL";
}
if (defaultinterval == undefined) {
defaultinterval = 6;
} else {
defaultinterval = Number(defaultinterval);
}
if (folder == undefined) {
folder = "";
}
checkslash = function () {
if (folder.length>0) {
if (folder.charAt(folder.length-1) != "/") {
folder += "/";
}
}
};
checkslash();
if (datafile == undefined) {
datafile = "inherit";
}
if (alphadelay == undefined) {
alphadelay = 7;
} else {
alphadelay = Number(alphadelay);
}
if (loop == undefined) {
loop = true;
} else {
if (loop == "true") {
loop = true;
} else {
loop = false;
}
}
if (clicktoreplay == undefined) {
clicktoreplay = true;
} else {
if (clicktoreplay == "true") {
clicktoreplay = true;
} else {
clicktoreplay = false;
}
}
i = 0;
photoindex = -1;
showimage = true;
nextimageloaded = false;
waiting = false;
checkvars = function () {
if (photos == undefined) {
getlist();
} else {
myphotos = photos.split(",");
myinterval = interval.split(",");
slide();
}
};
getlist = function () {
myvars = new LoadVars();
myvars.onLoad = function(success) {
if (success) {
myphotos = this.photos.split(",");
myinterval = this.interval.split(",");
if (this.defaultinterval != undefined) {
defaultinterval = Number(this.defaultinterval);
}
if (this.folder != undefined) {
folder = this.folder;
}
checkslash();
if (this.alphadelay != undefined) {
alphadelay = Number(this.alphadelay);
}
if (this.loop != undefined) {
if (this.loop == "true") {
loop = true;
} else {
loop = false;
}
}
if (this.clicktoreplay != undefined) {
if (this.clicktoreplay == "true") {
clicktoreplay = true;
} else {
clicktoreplay = false;
}
}
slide();
} else {
trace("unsuccess");
}
};
/*if (datafile == "inherit") {
datafile = this._url.substr(0, _url.length-3)+"txt";
}
trace(datafile);
myvars.load(datafile);*/
};
slide = function () {
i++;
photoindex++;
if (photoindex == myphotos.length) {
photoindex = 0;
}
var p = createEmptyMovieClip("photo"+i, i);
p.createEmptyMovieClip("internal",1);
loadMovie(folder+myphotos[photoindex], p.internal);
p._alpha = 0;
this.onEnterFrame = function() {
var l = p.internal.getBytesLoaded();
var t = p.internal.getBytesTotal();
if (l == t) {
preloader._visible = false;
delete this.onEnterFrame;
checkshow();
}
};
};
MovieClip.prototype.mfade = function() {
this.a = this._alpha;
this.onEnterFrame = function() {
this.a += (100-this.a)/alphadelay*2;
this._alpha = Math.round(this.a*1);
if (100-this.a<2) {
this.interval._alpha -= mytime;
delete this.onEnterFrame;
this.myinterval._alpha = 100;
this._alpha = 100;//dikai dene ke baad alpha
this._parent["photo"+(i-2)].mfadeOut.MovieClip();
}
};
};
//---------------------------------------
MovieClip.prototype.mfadeOut = function() {
this.b = this._alpha;
this.onEnterFrame = function() {
this.b += (0-this.b)/alphadelay;
this._alpha = Math.round(this.b);
if (0-this.b<2) {
//delete this.FadeOut.onEnterFrame;
this.myinterval._alpha = alphadelay;
this._alpha = 0;//dikai dene ke baad alpha
this._parent["photo"+(i-2)].removeMovieClip();
}
};
};
//------------------------------
checkshow = function () {
if (showimage || waiting) {
showimage = false;
waiting = false;
this["photo"+i].mfade();
if (myinterval[photoindex] != undefined) {
mytime = Number(myinterval[photoindex])*1000;
} else {
mytime = Number(defaultinterval)*1000;
}
mycounter = setInterval(counter, mytime);
if (photoindex<(myphotos.length-1) || loop) {
slide();
} else if (clicktoreplay) {
this["photo"+i].onPress = function() {
slide();
};
}
} else {
nextimageloaded = true;
this["photo"+i].mfadeOut();
}
};
counter = function () {
clearInterval(mycounter);
if (nextimageloaded) {
nextimageloaded = false;
showimage = true;
checkshow();
} else {
waiting = false;
}
};
checkvars();
stop();
//AS-2 ENDED
thanks
neeraj
XML Random Images Slideshow
I've created a flash slideshow with a fade-in fade-out effect that pulls a random image from a file containing a bunch of images from an XML file. This tutorial helped me out a lot.
http://www.webzo.org/tutorials/flash...-slideshow.php
Now what I'm trying to do is create some type of array that would generate those random images but maybe only 10 or so and just play those 10 images so that there aren't any duplicates one after another from pulling a random image from the file every time. Anyway, If anyone knows how this could be done preferably by modifying the code in the above tutorial, that would be awesome.
Random Slideshow But With SWF Files
I'd like to create a slideshow (but with swf files) and have it randomly pick which one will play next once the first one is done - and just have it continously running - and load the swf files into a mc externally.
I hope that makes sense... I'm new to this - so any suggestions, tutorials, or eved actionscript is much appreciated. Thanks.
XML Driven Random Slideshow.
Hi I am new to these forums and to Flash as well, pretty much. This seems to be about the best online community for flash that I have found. This is a great community. I did the Carousel tut, it was a great tutorial and Lee makes everything so easy to understand and grasp. I really like the concept of things being controlled by xml. I am currently working on a project where I would like to have an area where photos randomly fade in, stay for maybe 4 or 5 seconds and fade out to be replaced by a new one. I need no controls, but I would like the flash to call the photos and a caption from the xml file. I have the xml file and an idea of how it should go, but I seem to be stuck at the starting gate. Maybe some of you could offer some insight. I hope this is possible and that it makes sense to all of you. Thanks in advance for all your help.
Noods-
http://www.danhigbie.com
Random Image In XML Slideshow
I have a (very) basic XML slideshow. The slideshow appears on every page of a 7-page site. Is there a simple way to make the starting picture different on each of the 7 pages, without creating 7 different swfs & xml docs...?
I'm thinking some sort of onLoad get random image, then increment by +1...but if the random image was the seventh of eight images, how would I script it to loop to the beginning six...?
Probably basic, probably been asked before...please just point me in the right direction if this is a redundant question. (I did search first, but didn't find anything...)
Thanks for your time!!
SWF/movieclip Random Timed Slideshow
Basically I need help creating a slideshow that loads .swf or movieclip files, randomly and for a small period of time (i.e. 10-15 seconds) then changes. Also be able to have back and forward buttons. You can e-mail me at nabilkazerouni@yahoo.com
Simple Random Slideshow From Folder ?
Hi I am trying to find any good script how to make random slideshow from .jpg pictures in external folder ?
So I need these functions:
- pictures from external folder
- random order
- transition (not necessary)
I donīt need any buttons, components, just actionscript based simple automatic random slideshow from pictures I put into external folder.
Unfortunately I am not programmer, does anybody know solutions ?
Thanx in advance
P.
Random Loading Text From XML Slideshow
Hi!
I'm trying to load text into a dynamic text box from an external XML. My XML "test.XML" looks like this:
HTML Code:
<?xml version="1.0" standalone="yes"?>
<root>
<item>
<author>Namer Last</author>
<content>Blah bla bla bla bla bla.</content>
</item>
</root>
And I have two dynamic text boxes on my stage; one named "author_txt" the other named "content_txt"
Here is AS:
ActionScript Code:
var xmlFlash_xml:XML = new XML();
xmlFlash_xml.ignoreWhite = true;
xmlFlash_xml.onLoad = doit();
function doit(success) {
//onLoad event is triggered when the XML document hasbeen entirely loaded
if (success) {
trace('success');
// success is true if the XMl has been loaded with no errors, and false else
var l = this.firstChild.childNodes.length;
// firstChild property represents the rootnode of the XML document, childNodes property returns an array containing the children nodes of the current node. So, l variable holds the number of children of the root node
var c = Math.floor(Math.random()*l);
author_txt.text = this.firstChild.childNodes[c].childNodes[0].childNodes[0].nodeValue;
content_txt.text = this.firstChild.childNodes[c].childNodes[1].childNodes[0].nodeValue;
}
else {
trace("fail");
}
};
xmlFlash_xml.load("test.xml");
It fails to load. Any idea why?
Thanks!
Need Random Functionality For An Existing XML Slideshow
Hello,
I was using Emre Biberoglu's excellent slideshow as a base for a slideshow. Worked absolutely great, until my client asked for the slideshow to display the images in random order.
The untouched source is here:
http://www.biberoglu.com/flash/xmlslide/xmlslide.zip
I tried modifying the values that define the current image to something like: (Math.floor(Math.random() * nodeCount); to generate a random number as it is a common technique which worked well for me in the past.
The code is pretty clean, but for some reason, every attempt I made, the image number displayed doesn't match the image shown.
So... just a random function that works, if anybody wants to give it a try.
Cheers
Does Anyone Know Of Any Good Random Slideshow Scripts For Flash5?
Hi,
I want to create a slide show of my photographs. I need a script that would import photos randomly every 2 seconds to the main stage from an external folder [photos].
Also when you roll over the current photo it pauses the movie untill you rollout and shows a quick description.
Anyone have any ideas how to do this?
I did try one script that imported single .swf's randomly but there were loading problems on machines with modems and the fotos never appeared.
(There are 200+ fotos, about 15-20k each).
Thanks for your help.
Does Anyone Know Of Any Good Random Slideshow Scripts For Flash5?
Hi,
I want to create a slide show of my photographs. I need a script that would import photos randomly every 2 seconds to the main stage from an external folder [photos].
Also when you roll over the current photo it pauses the movie untill you rollout and shows a quick description.
Anyone have any ideas how to do this?
I did try one script that imported single .swf's randomly but there were loading problems on machines with modems and the fotos never appeared.
(There are 200+ fotos, about 15-20k each).
Thanks for your help.
Adding Fade-in To Xml Random Slideshow Flash
hi guys im working on a random slideshow gallery that uses xml to populate the mc, and it works great, but now i want to add a fade-in effect for each 1 of the pics, or maybe a cross-fade,this is the script i have so far, any help will be appreciated.
Code:
pauseTime = 2000;
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;
}
randomImage();
}
}
function randomImage() {
if (loaded == filesize) {
var ran = Math.round(Math.random() * (totalImages - 1));
picture_mc.loadMovie(imageFileName[ran], 1);
pause();
}
}
function pause() {
myInterval = setInterval(pause_slideshow, pauseTime);
function pause_slideshow() {
clearInterval(myInterval);
randomImage();
}
}
Starting With Random Image: Photo Slideshow Using XML And Flash
i want to strip this down and remove the image counter, description and buttons... which is easy enough.
but i would also like the starting image to be random. i mean, the first image that is loaded is selected randomly from the xml file.
can anyone help me with the real quick? here is the AS
delay = 6000;
//-----------------------
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");
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();
slideshow();
}
}
}
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();
slideshow();
}
}
function picture_num() {
current_pos = p+1;
pos_txt.text = current_pos+" / "+total;
}
function slideshow() {
myInterval = setInterval(pause_slideshow, delay);
function pause_slideshow() {
clearInterval(myInterval);
if (p == (total-1)) {
p = 0;
firstImage();
} else {
nextImage();
}
}
}
Why Do The Main Movie/site Close When I Load External Movie In A New Window?
When i want to load an external movie in a NEW window...why do my main site window close?????
this is how i load a movie in a new window...???
what is wront
_____________________________________________
on(release) {
loadMovie("mymovie.swf", _blank);
}
_____________________________________________
this happens when i test the movie
Thanks
Mirrorman
Client Loading My AS3 Movie Into An AS2 Movie, Need To Close My Movie Afterwards...
I created an AS3 animation, and a client is attempting to load my AS3 animation into an AS2 movie that someone else created. They emailed me and told me to add this to the end of my animation...
ActionScript Code:
_root.gotoAndPlay("Start");
I knew this wasn't going to work, and it won't even compile and throws an error. I know how to close an external movie using event triggers and listeners using AS3, but not really sure how it works with AS2. Any ideas?
Random Movie Clips To Play For Random Amount Of Time
hi,
i am loading external movieclips randomly into 4 seperate emptymovies, i now need a way to get these random clips that i am loading to play for a random amount of time and then load the next clip.
i need some help with the code...
how do i get the clips to loop, then assign each a random number and have flash check if the random num is = to current frame...if it is, have that clip stop and a new one load?
i have no idea how to write the code for this
any help would be great
thanks
this is what i was given so far..but don't know what to do with it.
Code:
var rnd = Math.round(Math.random(mc._totalframes));
mc.onEnterFrame = function() {
this._currentframe >= this._parent.rnd ? unloadMovie(this) : null;
}
Can You Close The Flash Movie Player When The Movie Is Done?
So I am giving up on the whole scrolling thing... LOL :-)
Anyway, my movie is now complete and it works the way I want it to. Now I would like to put a close button on it at the end... What Action script do I use to do this? The only thing that looks close to me is Unload Movie... but that just closes the movie and not the movie player..... I don't see a script that says close or anything????
TIA
Help: Multipule Random Positioned Duplicate Random Movie
Does anyone know a way that i can produce a button that when rolled over will duplicate x amount of movies each with random _x and _y positions? Basically i have a movieclip that will
gotoandPlay(math.Round((math.Random()*10)+1)
which randomises that frame that is played. This instance will then do some form of tweening and then gotoandPlay(1) again. I need a script that will then keep generating more duplicate movie clips whilst a button is moused over. i tried the following
on(mouseover){
i = 0;
rand_num = math.Round((math.Random()*29)+1);
while(i<20) {
duplicateMovieClip(_root.movie, "movie"+i,i);
setProperty("movie"+i, _x, _root.movie._x+(rand_num*5);
setProperty("movie"+i, _y, _root.movie._y+(rand_num*5);
i++
}
}
where movie = movieclip name
but this seems to generate all the clips on top of each other @ different depths. I want movies that are all in different positions. Can you help?
How Do I Close A Movie
I have a movie that playes on a button on the scene.
on this movie I have a cose button what code do I put in this to close the movie or make the movie invisible???
.................................................. ...
also anyone stil know how when yu put a new scene<preloader> infron of your main <scene 1 movie> the quality of the movie becomes real poor?????
hope sometone will help this time
thanx
Close Movie
Can you make a button in your movie that is able to close the file. Just like if you d-click on a swf file on your desktop and it opens and plays, the flash player has an X button to close the movie. Well can you make one within the movie to do the same ?
Close My Movie
Hi there everybody,
first a happy new year to all.
I'm looking for a option to close the window where my swf movie is playing in. It's a kind of browser without the toolbars.
I tried the java self.close, but it doesn't work.
who can help me out...??
thnx allready
Jonnekke
Close A Movie
I'm developing a CD-rom and I need to know how to exit the movie. It plays full screen so I wanted to put an "Exit" button on the bottom left, but what do I do from there???? HELP
How To Close Movie?
If I have a movie clip playing how do I create a button where "on mouse down" the movie clip will stop playing and close out?
Thanks in advance!
Megagoldy
Close Movie
Hi
I have completed tutorial 21, but now I need to close "MovieOne" from within the movie.
How do i do that?
Jo-Ann
Day 10 All I Want To Do Is Close A Movie
Ok,
I decided to make a new topic. I have been trying everything and I still can't make this work.
I made a web page that has a bunch of buttons that when rolled over shows an image and when clicked opens a video player on layer 50 over the image. I can not figure out how to make the movie(flv player in swf file) either just unload and stop when the flv player is done or close and stop when I hit a premade button that has the correct code from a tutorial book.
I have the flv file set as a progressive download in a seperate swf file and by using a premade button from the Lynda flash 8 book the button closes but the flv keeps playing which it shouldn't.
My ultimate goal is to have the swf movie with the FLV file to close as soon as the FLV file is finished playing.
Here's the Code for the swf file with the new close button.
on (release) {
unloadMovieNum(50);
}
Here's the code for the main site:
stop();
button1_btn.onRollOver = function(){
gotoAndstop(2);
}
button1_btn.onRelease = function(){
loadMovieNum("movieplayer1.swf", 50);
}
I'm starting to go crazy any help would be much appreciated.
Jason
Close Movie Help
Can anyone help me. I am trying to close my swf with a button. All that getURL jazz doesn't work because it is not an html wrapper and I can't use fscommand because it's not an exe.
Thanks
|