Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Westi on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How Do I Handle Image Not Found

Status
Not open for further replies.

neonwaters

Programmer
Feb 20, 2003
2
US
I am loading .jpg image into Flash MX. The problem I have is that the images are being updated and if you try to view the image with my Flash app and it is in the middle of an update the app freezes and must be restarted.

I am using the following code to load the image:

loadMovie("image.jpg", "my_display");

So, is there a way to handle an image not found ("Error opening URL") so that my Flash app will not crash?

Thanks,
neonwaters
 
using loadvars to test that the image has been found ought to work as the onload function checks for success. give it a try anyway and see what happens. you can always a couple of lines to check for success. ought to stop it freezing anyway.

mydata = new loadvars();
mydata.onload = check;
function check(){
if(success){
myimage = mydata.txt;
loadmovie(myimage,"my_display")
}else{//message
}
mydata.load("my.txt");


with my.txt having content txt=my_image.jpeg

not an elegant solution but maybe a workaround
 
i think that is a poor answer as on reflection its only to check if the text file has loaded not the image.....if i think of anything better i will post again.
 
Disable the viewing possibility until the jpg has completely loaded. You could also use a preloader to load your .jpgs in conjunction with a timer. If after so much time (to be determined), the bytes count of the jpg being loaded hasn't changed, consider it will not load or that there's a problem with that particular .jpg.

By the way hope your jpgs are not saved as progressive, because they'll definately not load! Regards,

oldman3.gif


Don't worry, if my reply is wrong, BillWatson will clean it up for me!
 
The .jpg files load just fine, I cut progressive off. The image is updated from a web cam program I have so I can not make it work with Flash. I am using flash to view the current image on-line. Right now I have flash load the image and then wait the load again. But as soon as you tell flash to load a .jpg image that is not there it locks up.
If I could just get it to check the size of the image (because it is always the same size) or just not lock up and try to load again that would be great.
So is there a way to grab the image but not load it so that I can check it first?
How do I get the size of the file from within flash?
Is there a way just to keep going even if the file is not found? I know that when I load .dat and .txt files for variables it does not matter if it finds the file or not, so why is a .jpg such a big deal.

What if I load a flash file that loads the image, then unload the file and load it again ever update. If the level 2 flash file has an error does it mess up the _level0? (I think I will check)

Thanks and please let me know if you find out anything.
~~neonwaters~~
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top