default image when loadMovie cant find the file

  • divx
  • Born
  • Born
  • divx
  • Posts: 3

Post 3+ Months Ago

Im stuck, I cant figure out how I can check if a file exist.

If a jpg file does not exist in a location, I want to load a default image:

Code: [ Select ]
getRandomProfile();
serverIn.onLoad =function(success){
try{_root.PIC.loadMovie("http://www.example.co.uk/Tuition/"+serverIn.ltName+"/upload/Tutors_Avatar.jpg?noCache=");}
catch(e){_root.PIC.loadMovie("http://www.exampke.co.uk/Tuition/Default/upload/Tutors_Avatar.jpg");}
  _root.PIC.gotoAndPlay(0);  
  }
  1. getRandomProfile();
  2. serverIn.onLoad =function(success){
  3. try{_root.PIC.loadMovie("http://www.example.co.uk/Tuition/"+serverIn.ltName+"/upload/Tutors_Avatar.jpg?noCache=");}
  4. catch(e){_root.PIC.loadMovie("http://www.exampke.co.uk/Tuition/Default/upload/Tutors_Avatar.jpg");}
  5.   _root.PIC.gotoAndPlay(0);  
  6.   }

The problem is, even when the file doesnt exist, the catch statement does not occur.
Is there any way in action script to check if a file exists?
  • Anonymous
  • Bot
  • No Avatar
  • Posts: ?
  • Loc: Ozzuland
  • Status: Online

Post 3+ Months Ago

  • graphixboy
  • Control + Z
  • Mastermind
  • User avatar
  • Posts: 1828
  • Loc: In the Great White North

Post 3+ Months Ago

"catch" is not a default AS function as far as I can tell. so what did you define as
Code: [ Select ]
function catch(e){
// something here
}
  1. function catch(e){
  2. // something here
  3. }

?

The easy way to do this is to use the MovieClipLoader Class and the onLoadError callback to check if the path exists. If flash can't load the file you give it something else.

Post Information

  • Total Posts in this topic: 2 posts
  • Users browsing this forum: No registered users and 19 guests
  • You cannot post new topics in this forum
  • You cannot reply to topics in this forum
  • You cannot edit your posts in this forum
  • You cannot delete your posts in this forum
  • You cannot post attachments in this forum
 
 

© 1998-2014. Ozzu® is a registered trademark of Unmelted, LLC.