default image when loadMovie cant find the file

  • divx
  • Born
  • Born
  • No Avatar
  • Joined: Jul 22, 2007
  • Posts: 3
  • Status: Offline

Post November 11th, 2007, 4:47 am

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
  • Joined: 25 Feb 2008
  • Posts: ?
  • Loc: Ozzuland
  • Status: Online

Post November 11th, 2007, 4:47 am

  • graphixboy
  • Control + Z
  • Mastermind
  • User avatar
  • Joined: Jul 11, 2005
  • Posts: 1828
  • Loc: In the Great White North
  • Status: Offline

Post November 13th, 2007, 12:28 pm

"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.
If at first you don't succeed F1... If that doesn't work try Google!
//// Designer, Developer & Teacher - Interactive, Motion and 3D \\\\
Portfolio at WhenImNotSleeping.com

Post Information

  • Total Posts in this topic: 2 posts
  • Users browsing this forum: No registered users and 31 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
 
 

© 2011 Unmelted, LLC. Ozzu® is a registered trademark of Unmelted, LLC.