473,322 Members | 1,523 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,322 software developers and data experts.

loading all images from the desktop to the stage (AIR)

258 100+
Hi everyone
I'v been trying to open image files from local disk and putting them on the stage with no luck.

Here's the code:
Expand|Select|Wrap|Line Numbers
  1. var currentPath = File.desktopDirectory;
  2. var dirListing:Array = currentPath.getDirectoryListing();
  3.  
This code returns the list of all files on the desktop. Now I need to load all JPG files and add them to the stage.

I tried with URLRequest and URLLoader but it didn't work. I think i'm doing something wrong

Thanks
Behzad
Jan 13 '13 #1

✓ answered by bnashenas1984

Finally I got it fixed.
I post it here for someone who might need

Expand|Select|Wrap|Line Numbers
  1. var currentPath = File.desktopDirectory;
  2. var dirListing:Array = currentPath.getDirectoryListing();
  3. var myLoader:Loader:Loader;
  4. var myFile:URLRequest;
  5. for (var i = 0; i < dirListing.length; i++) { 
  6.     myLoader:Loader = new Loader();
  7.     myFile = new URLRequest(dirListing[i].url);
  8.     myLoader.load(myFile);
  9.     stage.addChild(myLoader);
  10. }
  11.  
But this code assumes that all files are images. You need to check if the current file dirListing[i] is an image then add it to the stage

Good luck
Behzad

1 2262
bnashenas1984
258 100+
Finally I got it fixed.
I post it here for someone who might need

Expand|Select|Wrap|Line Numbers
  1. var currentPath = File.desktopDirectory;
  2. var dirListing:Array = currentPath.getDirectoryListing();
  3. var myLoader:Loader:Loader;
  4. var myFile:URLRequest;
  5. for (var i = 0; i < dirListing.length; i++) { 
  6.     myLoader:Loader = new Loader();
  7.     myFile = new URLRequest(dirListing[i].url);
  8.     myLoader.load(myFile);
  9.     stage.addChild(myLoader);
  10. }
  11.  
But this code assumes that all files are images. You need to check if the current file dirListing[i] is an image then add it to the stage

Good luck
Behzad
Jan 14 '13 #2

Sign in to post your reply or Sign up for a free account.

Similar topics

1
by: Nick | last post by:
How to change the pic to a "show error" image when loading images failed - for example, no image file exists? I tried to add the following statement in the onload event function: if...
10
by: John Ortt | last post by:
Hi Everyone, I have created a Javascript menu for my site which uses frames. The first stage loads fine but I want two drill down menus ("About Me Menu" and "Projects Menu"). The pages load...
3
by: John Ortt | last post by:
Hi everyone, I posted with the title "Javascript Menu Not Loading Images" last week but I only posted the code as the site was on a corporate Intranet. Thanks to advice on the thread I have...
9
by: josvanr | last post by:
HI I'm working on a site http://www.josvanriswick.nl/nieuw in which i use absolute positioning. On my pc at home i didn't notice, but now, as the site is on air and loading images is a bit...
10
by: windandwaves | last post by:
Hi I have the following html: <div id="menu"> <div id="m1"><a href="m1.php"><img src="m1.gif" alt="m1"></a></div> <div id="m2"><a href="m2.php"><img src="m2.gif" alt="m2"></a></div> <div...
15
by: Geoff Cox | last post by:
Hello I have following type of code in the header function pre_load_pics() { if (document.images) { var image1 = new Image(400,265); image1.scr = "pic1.jpg";
2
by: John | last post by:
Hi all, I'm having a problem loading images for later use in javascript on the client. In my code-behind, I'm using a stringbuilder object to build and populate a few javascript variables like :...
4
by: VR | last post by:
Hi, I am trying to have a menu item (which is an HTML img) to change as a mouse moves over it. So, my code looks something like this: <a onmouseover="ActivateImage('MyImage');"...
6
by: Ivan Bútora | last post by:
I have recently looked at http://alistapart.com/articles/imagegallery to implement a simple picture gallery on a webpage that I'm working on. Everything works fine; however, I have one question....
1
by: mlikesit | last post by:
I am trying to get the following code to pre-load some images before re-dirrecting the user. The problem is that the onError event gets called for all of the images immediately. I've tripple...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.