Saulius Antanavicius
Saulius Antanavicius

Reputation: 1381

Loading images into flash from directory

I've been trying to figure this out while im reinstalling flash(preview the work once and then wont let you do it again)

anyway what im trying to achieve is - AS reads a directory on a server lets say, it contains 10 images, this would create movie clips for each one and assign them to array "pockets"(im not sure if you can do this in AS, you can in PHP and JS so I'd expect so) then I'd use a repetitive function to manipulate each one of those images.

Could someone give me some guidance? Thank you!

Upvotes: 0

Views: 145

Answers (2)

Marty
Marty

Reputation: 39466

Try a combination of FlashVars and scandir() in PHP.

The process would basically be:

  1. Use scandir() (PHP) to generate a list of images in a directory.
  2. Use implode() (PHP) to convert the list to a string.
  3. Send the string to flash using FlashVars (HTML).
  4. Use split() (AS3) to convert your string back to a list of images.
  5. Use the Loader class to add your images into the DisplayList.

Upvotes: 2

Samuel Neff
Samuel Neff

Reputation: 74949

Flash cannot read a directory directly, neither can client-side JavaScript. You need server side code to give you a directory listing, like PHP or Java or ASP.NET. Once you have the directory listing, you create an array and dynamically load the images into a movieclip.

Here's a tutorial on creating on loading images without using components.

http://flashexplained.com/actionscript/loading-external-jpgs-into-your-main-swf-movie/

It's easier with components, but whether or not you want to use them depends on your situation and requirements.

Upvotes: 1

Related Questions