Solved

can not dynamiacally load images in FLEX

Posted on 2008-10-20
5
1,465 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 500 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

What Is Transaction Monitoring and who needs it?

Synthetic Transaction Monitoring that you need for the day to day, which ensures your business website keeps running optimally, and that there is no downtime to impact your customer experience.

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…
Article by: Justin
In light of the WannaCry ransomware attack that affected millions of Windows machines, you might wonder if your Mac needs protecting. Yes, it does and here is how to do it.
This is a high-level webinar that covers the history of enterprise open source database use. It addresses both the advantages companies see in using open source database technologies, as well as the fears and reservations they might have. In this…
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 …

717 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