all groups > macromedia flash sitedesign > february 2005 >
You're in the

macromedia flash sitedesign

group:

FLASH MASTERS NEEDED! - Loading Dynamic Images into Flash


FLASH MASTERS NEEDED! - Loading Dynamic Images into Flash Quasimotolioli
2/25/2005 7:23:16 PM
macromedia flash sitedesign:
THE PLAN: I am using Flash MX 2004 and I want to build something that loads a
series of .jpg images dynamically. I want the images to either load randomly
or sequentially, doesn't matter, from a images dir on my server. THE PROBLEM:
I have searched endlessly on the web in tutorials, forums, etc. for an answer
to this so there must a master out there somewhere to help me. I have made the
script in flash that can pull images into flash dynamically from a images
directory and rotate them in sequence just fine. HOWEVER, if I do not
predefine the image names (i.e. '1.jpg', '2.jpg, '3.jpg', etc.) then flash
doesnt know what the images are to load. ALSO, if I redefine a certain number
of images (i.e. 10) then if the image directory only contains 8 images , then
the animation rotates through the first 8, then two blank spaces, then
restarts. Its not smart enough to ignore the two blank images and just restart
the cycle without a gap in between. THE SOLUTION: So really I need something
that can rotate images dynamically that I dont have to define a specific number
of images or their specific file names before hand. That way I can just load
new images into that directory when I have them without ever having to update
that part of the flash file each time a want another image in the animation.
PLEASE help me or direct me to a URL that might have more info. Thanks
Re: FLASH MASTERS NEEDED! - Loading Dynamic Images into Flash jolyon_russ
2/27/2005 8:12:10 PM
The way I see it you have a couple of options.

The first is to use XML to hold the locations of your images, load the XML
into an array, cycle through the array and load you images into a MC. The XML
file will need manual updating but your swf won't. This is a tried and tested
method to load dynamic content and is well documented on the web.

The second option I'm not 100% sure about but is probably possible. You use
PHP to look at your dir and write the XML file every 24 hours. Then all you
would need to do then upload the pics to the right dir.

Hope this helps.


Jolyon
Re: FLASH MASTERS NEEDED! - Loading Dynamic Images into Flash Peter Blumenthal
2/28/2005 10:12:24 AM

[quoted text, click to view]

Much simpler to simply use PHP, or ASP, CGI, JSP, whatever, to return to
Flash a listing of the relevant directory via loadVariables or the LoadVars
class (check ActionScript dictionary)

BTW, please don;t cross post - counter productive and a bit rude.

Re: FLASH MASTERS NEEDED! - Loading Dynamic Images into Flash MyFlashMXIN
3/16/2005 2:03:52 PM
<?php //abcchoose.php // Attempt connection to MySQL server $link =
@mysql_connect('localhost','root','mysql'); if ($link == false) { echo
'&amp;result=Fail&amp;errormsg='; echo urlencode('Failed to connect to MySQL
server!'); echo '&amp;'; exit; } // Attempt to select our DB if
(mysql_select_db('flash') == false) { echo '&amp;result=Fail&amp;errormsg=';
echo urlencode('Error selecting database!\n'); echo urlencode('Error: ' .
mysql_error($link)); echo '&amp;'; exit; } // Build and execute query
$query = 'SELECT * FROM main ORDER BY RAND()'; $result = @mysql_query($query);
$count = 0; $output = ''; while ($row = mysql_fetch_array($result)) {
//$folder = stripslashes($row['folder']); $Text1 = stripslashes($row['Text']);
$pic1 = stripslashes($row['pic1']); ; //$output .= '&amp;folder' . $count .
'=' . urlencode($folder); $output .= '&amp;Text' . $count . '=' .
urlencode($Text1); $output .= '&amp;pic1' . $count . '=' . urlencode($pic1);
$output .= '&amp;id' . $count . '=' . urlencode($count); $count++; } echo
$output . '&amp;records=' . $count . '&amp;result=Okay&amp;'; ?>

function loadmember(index, slot)
{
_root["Text" + slot] = myData["Text" + index];
_root["pic" + slot].loadMovie("picfolder/" + myData["pic1" + index]);
} // End of the function
function swapImg()
{
var _l1 = _root;
_l1.numer2 = _l1.numer2 + 1;
if (_l1.numer2 >= myData.records)
{
_l1.numer2 = 0;
} // end if
loadmember(_l1.numer2, 1);
} // End of the function
myData = new LoadVars();
myData.load("abcchoose.php?nocache");
myData.onLoad = function (success)
{
if (success)
{
loadmember(0, 1);
animIntreval = setInterval(swapImg, 3000);
}
else
{
statuswho = "Error";
} // end if
};
Re: FLASH MASTERS NEEDED! - Loading Dynamic Images into Flash MyFlashMXIN
3/16/2005 2:08:23 PM
You can see how it works by glancing at...

http://www.rjbagan.com/

AddThis Social Bookmark Button