Friday, March 26, 2010

Loading random images in intervals

I am very new to doing ActionScripts and I want to create an
applet which reads from an XML and builds an array of the URL for
images, then loads the images in a repeat with about 5 second
intervals without the use of any buttons. Here's what I have in my
actionscript coding, but what does not seem to work is the ability
to switch images in a loop. How can I do that?



Loading random images in intervals
hello?



I figured how to do setInterval but am still still stuck on
why I cannot replace images.



Help!Loading random images in intervals
Hi



Can you post a sample of your XML structure, I can see how
your loading your image into your mc.

I think your problem is your creating a new emptymovieclip
'mc' on every pass, and not loading it one pre-defined
img_holder!!!!



Hope it helps
Thanks for the reply.



Here's a sample of my XML file as it is basically used to
create a single array to contain a relative URL of the image to
use:



%26lt;?xml version=''1.0'' encoding=''UTF-8''?%26gt;

%26lt;imglist%26gt;

%26lt;imgfile%26gt;images/N85735_101_12.jpg%26lt;/imgfile%26gt;

%26lt;imgfile%26gt;images/N86579_101_12.jpg%26lt;/imgfile%26gt;

%26lt;imgfile%26gt;images/N86712_101_12.jpg%26lt;/imgfile%26gt;

%26lt;imgfile%26gt;images/N86716_101_12.jpg%26lt;/imgfile%26gt;

%26lt;/imglist%26gt;
OK - I have created a new .fla that will do what you want.

Send me an email address and I can send you the file.



Just mention that the randomization of images may need
playing around with, but the more images you have the less likely
you will have repetition so close together.



Ciao for Now
OK! to place multiples of the same Symbol on the Stage we
need to change the instance name slightly for each one.



The easiest way to do this is to place the amount (multiple)
into a for...loop. In your case you need four items



for(c=0;c%26lt;=3;c++)

{

var mc = home.attachMovie(''imageContainer'', ''imageContainer''
+ c, 1+c);

mc._x = ?; // you will need to calculate x for each symbol

mc._y = ?; // also with y

}



So basically we have created imageContainer0 to
imageContainer3 and using c+1 we have them on different depths.

Now all you have to do is reference each one in your
loadImage loop.



Hope it helps
Thanks for your assistance The FeldKircher as I'm trying to
understand the following line of code:



var mc = home.attachMovie(''imageContainer'', ''imageContainer''
+ c, 1+c);



So if I understand correctly, the first parameter will be the
object name in the library, and the 2nd (imageContainer0, etc...)
is each instance?



Edit: I think I finally got it to work as desired. Just a few
things I'll need to cleanup in my coding. While the XML file I've
been using has been simple enough to only contain the image URL, I
am thinking later on I may want to expand on it such as having
certain text and/or perhaps a linkable URL so that each image can
have a link to click to.
Hi



No Problem, glad to help.



You got it, imageContainer is the Linkeage identifier of the
library MovieClip, imageContainer0..etc is the Instance name.



Extending what you have is a good idea, do you intend to open
the image in its own window or on Stage?.






I believe this will be as far as I'll go with this particular
project though I may revisit at some point later on. One thing I do
notice is that it saves the resource files to the Temporary
Internet Files folder so I may want to limit the image rotation to
a certain amount. The images I am using are relatively small (150 x
150 in pixels) so hopefully that won't be too much of a problem if
I limit it to say the first 80-100 images out of a possible
many.
  • cosmetic products
  • No comments:

    Post a Comment