can not dynamiacally load images in FLEX

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.
LVL 1
tomcattyyAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Gary BenadeCommented:
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
tomcattyyAuthor Commented:
Sorry for the typo, I do have the i in file name for both image, and loader
0
Gary BenadeCommented:
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

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
tomcattyyAuthor Commented:
I am transfering it to the web server, so far I am testing from the local machine. Will advice results shortly. thanks
0
tomcattyyAuthor Commented:
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
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Apache Flex

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.