Home Tutorials Forums Articles Blogs Movies Library Employment Press
Old 06-02-2006, 12:54 PM   #11
sophistikat
Game On
 
sophistikat's Avatar
 
Join Date: Mar 2005
Location: Barrie, ON
Posts: 2,535
Default

you need XML to make this automatic, let me show you how;
xml: create an xml file with all your images and their description
HTML Code:
<?xml version='1.0' encoding='UTF-8'?>
<library>
	<jpg>
		<file>fotos/foto0.jpg</file>
		<desc>Antigua</desc>
	</jpg>
	<jpg>
		<file>fotos/foto1.jpg</file>
		<desc>Flag's Emblem</desc>
	</jpg>
	<jpg>
		<file>fotos/foto2.jpg</file>
		<desc>Village</desc>
	</jpg>
	<jpg>
		<file>fotos/foto3.jpg</file>
		<desc>Mayan Girl</desc>
	</jpg>
	<jpg>
		<file>fotos/foto4.jpg</file>
		<desc>Lake Atitlan</desc>
	</jpg>
</library>
flash: gallery is now based on the information from our xml file
ActionScript Code:
//: SETUP INITIAL VARIABLES var oldVar = 0; var newVar = 0; var si = 0;   //: GET XML var my_xml = new XML (); my_xml.ignoreWhite = true; my_xml.onLoad = function (success) {     if (success) {         library = this.firstChild.childNodes;         maxVal = library.length;         delete my_xml;         getImage ();     } else {         desc_txt.text = 'Error: XML Not Loaded';     } }; my_xml.load ('library.xml');   //: LOAD THE NEXT IAMGE function getImage () {     newVar = Math.floor (Math.random () * maxVal);     if (newVar == oldVar) {         getImage ();     } else {         oldVar = newVar;         container_mc.loadMovie (library[newVar].firstChild.firstChild.nodeValue);         container_mc._alpha = 0;         this.onEnterFrame = function () {             if (container_mc._width > 0) {                 container_mc._x = Stage.width / 2 - container_mc._width / 2;                 container_mc._y = Stage.height / 2 - container_mc._height / 2;                 container_mc.onEnterFrame = fadeIn;                 desc_txt.text = library[newVar].firstChild.nextSibling.firstChild.nodeValue;                 delete this.onEnterFrame;             }         };     } }   //: FADE IN THE CURRENT MOVIECLIP function fadeIn () {     if (this._alpha <= 100) {         this._alpha += 5;     } else {         this._alpha = 100;         delete this.onEnterFrame;         si = setInterval (fadeOut, 2000);     } }   //: FADE OUT THE CURRENT MOVIECLIP function fadeOut () {     clearInterval (si);     container_mc.onEnterFrame = function () {         if (this._alpha >= 0) {             this._alpha -= 5;         } else {             this._alpha = 0;             delete this.onEnterFrame;             getImage ();         }     }; }
once you've designed your gallery in flash, all you need to do is edit the xml file to see your changes; no need to publish the swf file again.
good luck with your gallery,
sophistikat

+
learn more:
Introduction to XML in Flash
XML Object
Attached Files
File Type: zip random_galleria_v3.zip (25.9 KB, 1140 views)

Last edited by sophistikat; 06-05-2006 at 03:28 PM. Reason: adding code & attachment
sophistikat is offline   Reply With Quote
Old 06-04-2006, 11:37 AM   #12
Peter Cherry
Registered User
 
Join Date: May 2006
Posts: 77
Default

Ok I didn´t want to use any additional things like XML file, but I will see, what is better for me - additional XML file or regenerating SWF Nevertheless many thanks for code
Peter Cherry is offline   Reply With Quote
Old 06-05-2006, 07:32 AM   #13
Peter Cherry
Registered User
 
Join Date: May 2006
Posts: 77
Default

So it is Monday morning and I decided to use XML version of your code It is better than regenerating .sfw But are you 100% sure taht Flash is not able to count number of .jpg files in folder ? I would leave picture description but automatic possibility of adding pictures to folder would be great.

But on the other side, scomplete solution through XML is also good...
Peter Cherry is offline   Reply With Quote
Old 06-05-2006, 12:45 PM   #14
sophistikat
Game On
 
sophistikat's Avatar
 
Join Date: Mar 2005
Location: Barrie, ON
Posts: 2,535
Default

Quote:
Originally Posted by Peter Cherry
But are you 100% sure taht Flash is not able to count number of .jpg files in folder ?
yes, you need a php script to read the contents of a folders so here's a link to a tutorial with source files on how to complish this; EMLlabs article: Sequential Image Loader 2.0 - Using PHP to do all the hard work


good luck,
sophistikat
sophistikat is offline   Reply With Quote
Old 07-25-2006, 06:51 AM   #15
Peter Cherry
Registered User
 
Join Date: May 2006
Posts: 77
Default

Hi,
it is some time ago, but back to Sophistikat code...what about diacritic ? When I use letters like ěščřžýáí slideshow get stop working...
Peter Cherry is offline   Reply With Quote
Old 02-16-2007, 12:13 PM   #16
Peter Cherry
Registered User
 
Join Date: May 2006
Posts: 77
Default

So I am using former code for loading external images via XML. Images are loading in random order, but they are repeating sometimes

What should I add to the code, to have random order but with repeating after all pictures were displayed ?
Peter Cherry is offline   Reply With Quote
Old 02-16-2007, 03:17 PM   #17
sophistikat
Game On
 
sophistikat's Avatar
 
Join Date: Mar 2005
Location: Barrie, ON
Posts: 2,535
Default

check out some random prototypes at http://proto.layer51.com/default.aspx
__________________
Available freelancer
http://www.outsidethecubicle.ca
sophistikat is offline   Reply With Quote
Old 02-16-2007, 03:47 PM   #18
Peter Cherry
Registered User
 
Join Date: May 2006
Posts: 77
Default

As non programmer, I am afraid, it is not very clear to me

I think I should rewrite somehow the following part:

newVar = Math.floor (Math.random () * maxVal);
if (newVar == oldVar) {
getImage ();
} else {

but how ?
Peter Cherry is offline   Reply With Quote
Old 02-19-2007, 08:22 AM   #19
Peter Cherry
Registered User
 
Join Date: May 2006
Posts: 77
Default

I have also one theoretical question: When I run this slideshow in separate movie, everything works fine. But in case of implementing it into more complex movie, where I also have other actionscripts (external typewriter style text fed also form XML files), there is strange thing:

Sometimes this slideshow displays for example 20 pictures and than stops, sometimes only 3-5 pictures, sometimes even 1 picture and than stops...???

Is it possible that there are some interactions ? As I said, I am beginner with actionscript...where could be problem.... ? what about this.firstChild.nodes....or in some variables ???

Any experiences
Thanx
Peter
Peter Cherry is offline   Reply With Quote
Old 06-11-2007, 09:48 AM   #20
soft_machine
Registered User
 
Join Date: Jun 2007
Posts: 2
Default

Hey Sophistikat!
Wicked script.
One question...is there any way to load sets of random images via xml from different image directories - it's cool with one images folder, but I'd like to use more and have them load randomly.
soft_machine is offline   Reply With Quote
Reply


Thread Tools
Display Modes 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 Off
HTML code is Off

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Problem in Image loading useing loader component vsflash ActionScript 2.0 2 02-02-2006 06:50 AM
loading external image files and preloading them. laffer ActionScript 2.0 0 01-30-2006 07:48 PM
Preload external image into external swf Vercixxx ActionScript 2.0 1 01-13-2006 01:13 PM
Scrolling an External Image In A Textfield gilnoy ActionScript 2.0 0 11-05-2004 10:08 AM
How to copy loaded image from one mc to another? sendres ActionScript 1.0 (and below) 3 08-19-2003 11:33 AM


All times are GMT. The time now is 03:06 PM.

///
Follow actionscriptorg on Twitter

 


Powered by vBulletin® Version 3.8.5
Copyright ©2000 - 2014, Jelsoft Enterprises Ltd.
Ad Management plugin by RedTyger
Copyright 2000-2013 ActionScript.org. All Rights Reserved.
Your use of this site is subject to our Privacy Policy and Terms of Use.