all groups > flash actionscript > december 2004 >
You're in the

flash actionscript

group:

Animate Pics ......Dynamically populate the animation


Animate Pics ......Dynamically populate the animation Bears51
12/18/2004 9:56:56 PM
flash actionscript:
I am creating a website that requires the use of a lot of pictures. I have
designed a window where I would like these pictures to animate in and out. I am
embedding the swf into html. I would like the pictures to come in from a file
on server. I would like the ability to change the pictures in and out depending
on the clients wants without changing the whole swf. Is this possible? What
should I be carefule with ie bandwidth, picture size ect. and most important
How do i do this. I know how to animate but have no idea how to populate the
animation dynamically with Actionscript. I hope this is clear. Thanks for your
help Ray
Re: Animate Pics ......Dynamically populate the animation kglad
12/18/2004 11:42:38 PM
the pictures can't come from a file on the server, but a reference (ie, their
names) can come from a file on the server. the simplest would be an ascii text
file that would contain your pic's file names.

if you're going to load the pics directly into flash they will need to be
non-progressive jpg's. you'll write actionscript or otherwise animate the
target movieclips into which you'll load these jpgs.
Re: Animate Pics ......Dynamically populate the animation Bears51
12/19/2004 11:18:51 PM
Re: Animate Pics ......Dynamically populate the animation kglad
12/20/2004 1:50:50 AM
_root.createEmptyMovieClip("dataHolder", 0);
dataHolder.loadVariables("yourTextFile.txt");
ivar = 1;
preloadA = new Array();
dataHolder.onData = function() {
for (obj in dataHolder) {
if (typeof (dataHolder[obj]) == "string") {
dataHolder[obj] = dataHolder[obj].split("
").join("").split("\r").join("").split("\n").join("");
rclip = _root.createEmptyMovieClip("mc"+i, i);
rclip.loadMovie(dataHolder[obj]);
preloadA[ivar] = setInterval(preloadF, 100, ivar);
ivar++;
}
}
picNum = ivar-1;
preload();
};
function preloadF(ivar) {
loaded = _root["mc"+ivar].getBytesLoaded();
total = _root["mc"+ivar].getBytesTotal();
if (loaded>0 && loaded>=total) {
animateF(ivar);
clearInterval(preloadA[ivar]);
}
}
function animateF(ivar) {
// do whatever here to animate _root["mc"+ivar]
}
Re: Animate Pics ......Dynamically populate the animation kglad
12/20/2004 1:56:59 AM
p.s. this assumes yourTextFile.txt looks like:

pic1=yourfirstpic.jpg
&pic2=2ndpic.jpg
&pic3=3rd.jpg
etc

it doesn't matter what variable names are used. ie, pic1,... or var1,... or
anything else. all that split/join stuff is to clear out white space so we
have yourfirstpic.jpg, 2ndpic.jpg, 3rd.jpg etc.
Re: Animate Pics ......Dynamically populate the animation Bears51
12/21/2004 2:44:58 AM
Re: Animate Pics ......Dynamically populate the animation Bears51
12/24/2004 10:50:12 PM
Re: Animate Pics ......Dynamically populate the animation kglad
12/24/2004 11:23:09 PM
_root.createEmptyMovieClip("dataHolder", 0); // creates a movieclip to hold
the data
dataHolder.loadVariables("yourTextFile.txt"); // initiates data load into
dataHolder
ivar = 1;
preloadA = new Array();
dataHolder.onData = function() { // this function executes when data loading
is complete
for (obj in dataHolder) { // this cycles through all variables, objects etc
in dataHolder
if (typeof (dataHolder[obj]) == "string") { // this checks for all strings in
dataHolder
dataHolder[obj] = dataHolder[obj].split("
").join("").split("\r").join("").split("\n").join(""); // this eliminates all
carriage returns and new lines in the string variables
rclip = _root.createEmptyMovieClip("mc"+i, i); // this creates movieclips
into which the string references are loaded
rclip.loadMovie(dataHolder[obj]); // loads into rclip
preloadA[ivar] = setInterval(preloadF, 100, ivar); // initiates loops to
determine when loading is complete
ivar++;
}
}
picNum = ivar-1;
preload();
};
function preloadF(ivar) { // load completion checks
loaded = _root["mc"+ivar].getBytesLoaded();
total = _root["mc"+ivar].getBytesTotal();
if (loaded>0 && loaded>=total) {
animateF(ivar); // loading is complete. can initiate animation
clearInterval(preloadA[ivar]); // terminate this setInterval() loop
}
}
function animateF(ivar) {
// do whatever here to animate _root["mc"+ivar]
}
AddThis Social Bookmark Button