A Flash Developer Resource Site

Results 1 to 6 of 6

Thread: Loading Images From File

  1. #1
    Junior Member
    Join Date
    Feb 2001
    Posts
    20

    Loading Images From File

    I need to create an interface that displays image files in a gallery by pulling them dynamically from a folder. I know that this is easily achieved by saving the images in a folder and then dynamically loading them in with actionscript.

    However i need to cater for the possibility that the number of images saved in the folder will increase so I cannot hard code the image names into the actionscript.

    Is there a way to set up a system that allows new images to be saved in a folder and flash will dynamically pull them into the movie?

    Thanks

  2. #2
    Senior Member
    Join Date
    Sep 2005
    Location
    Detroit
    Posts
    193
    use an XML file. I know it's not as easy as you would like it to be but that way you can add the images with a text editor. That's the best way to do this.
    While the music played you worked by candlelight
    Those san francisco nights
    You were the best in town
    Just by chance you crossed the diamond with the pearl
    You turned it on the world
    That’s when you turned the world around

  3. #3
    Member
    Join Date
    Aug 2006
    Posts
    56
    You could also label the images numerically (i.e. 1.jpg, 2.jpg, 3.jpg) and have flash load 'variable + ".jpg"' or something of that sort. You would have to check if the load was successful, and if it was, you would increment the variable by 1. It would continue to load images until it failed to find one.

  4. #4
    Senior Member
    Join Date
    Sep 2005
    Location
    Detroit
    Posts
    193
    That's a cool idea. Thanks, Eldiran
    While the music played you worked by candlelight
    Those san francisco nights
    You were the best in town
    Just by chance you crossed the diamond with the pearl
    You turned it on the world
    That’s when you turned the world around

  5. #5
    FK'n_dog a_modified_dog's Avatar
    Join Date
    Apr 2003
    Location
    "aaarf"
    Posts
    9,176
    if your server supports PHP, you can use it to search your folder and output the results to Flash

  6. #6
    Junior Member
    Join Date
    Apr 2007
    Posts
    10

    upload images

    this will allow you to up load any jpeg image
    you may need to change the content path.

    import flash.net.FileReference;
    var listener:Object = new Object();
    if (photo.data.name != undefined) {
    myloader.contentPath = photo.data.name;
    }
    browse_btn.onRelease = function() {
    listener.onSelect = function(file:FileReference):Void {
    trace("Opened "+file.name);
    //if (file.name != undefined) {
    myloader.contentPath = "C:/Documents and Settings/Jeff Collier/Desktop/projectjeff/saved items/Images.swf/"+file.name;
    photo.data.name = file.name;
    //trace("this should load");
    //}
    };
    listener.onCancel = function(file:FileReference):Void {
    trace("User cancelled");
    };
    var fileRef:FileReference = new FileReference();
    fileRef.addListener(listener);
    fileRef.browse();
    };

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  




Click Here to Expand Forum to Full Width

HTML5 Development Center