?
Solved

can not dynamiacally load images in FLEX

Posted on 2008-10-20
5
Medium Priority
?
1,466 Views
Last Modified: 2012-05-05
Hello there,

I am trying to load images in flex 3 dynamically. I have the image file name start with same number and with a trailer like 15652_1.jpg, 15652_2.jpg,15652_3.jpg...but I did not know how many of them.
If I use a small loop like

for (var i:int=1; i<20; i++){ var img:Image=new Image();
img.source="../Photos/"+"15652"+"_.jpg";
holder.addChild(img);
}
I will have images add into the holder but with broken image from 13 to 20 because it's not there.

I was trying with
private function getphoto():void{
for (var i:int=1; i<20; i++){
var loaderi:Loader=new Loader();
var ui:UIComponent=new UIComponent();
var requesti=new URLReruest=("../Photos/"+"15652"+"_.jpg");
loaderi.load(requesti);
ui.addChild(loaderi)
hoder.addChild(ui)
} }
I will got
Error #2044: Unhandled IOErrorEvent:. text=Error #2036: Load Never Completed. for the first 11 images
only the last one loaded.
My question is is there a way I can loop through image and detect what file was not in the folder and not adding them to the folder?
Or if I have to use loader then why only the last one was shown?
Thanks for your answer.
0
Comment
Question by:tomcattyy
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
  • 2
5 Comments
 
LVL 19

Expert Comment

by:Gary Benade
ID: 22766445
Is the code you posted correct? You are not using the variable i in the filename?

var requesti=new URLReruest=("../Photos/"+"15652"+"_" + i + ".jpg");
0
 
LVL 1

Author Comment

by:tomcattyy
ID: 22767976
Sorry for the typo, I do have the i in file name for both image, and loader
0
 
LVL 19

Accepted Solution

by:
Gary Benade earned 2000 total points
ID: 22768832
OK. An IOError means the file could not be found, as a starting point you could try changing your url's to absolute:

var requesti=new URLReruest=("http://yourserver/Photos/"+"15652_" + i + ".jpg");

As a test, if you can open the path http://yourserver/Photos/15652_5.jpg in a browser then it's OK and the loader should load it.
0
 
LVL 1

Author Comment

by:tomcattyy
ID: 22769499
I am transfering it to the web server, so far I am testing from the local machine. Will advice results shortly. thanks
0
 
LVL 1

Author Comment

by:tomcattyy
ID: 22769729
Hello hobbit72,

That's super, I got it to run after the absolute path and with try catch steps like
try {    loaderi.load(requesti);}
      catch (error:SecurityError) {
    trace(error);}
ui.addChild(loaderi);ui.y=260*(i-1); ui.x=50;
holder.addChild(ui)

and It sowed up. Thanks
0

Featured Post

WatchGuard's M Series Appliances - Miecom Approved

WatchGuard's newest M series appliances were put to the test by Miercom.  We had great results and outperformed all of our competitors in both stateless and stateful traffic throghput scenarios! Ready to see how your UTM appliance stacked up? Download the Miercom Report!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

First things first - Preparation We need all the part for this install and it's much nicer to have them all on hand when you need them so here's what's required. Download Eclipse 3.5 32 bit (I like the Classic flavour) from here. (http://www.e…
Learn how to use the free Acronis True Image app to easily transfer data between iPhones and Android phones.
Monitoring a network: how to monitor network services and why? Michael Kulchisky, MCSE, MCSA, MCP, VTSP, VSP, CCSP outlines the philosophy behind service monitoring and why a handshake validation is critical in network monitoring. Software utilized …
In this video you will find out how to export Office 365 mailboxes using the built in eDiscovery tool. Bear in mind that although this method might be useful in some cases, using PST files as Office 365 backup is troublesome in a long run (more on t…
Suggested Courses

762 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question