# Using "Error opening URL" as a variable

**URL:** <https://forum.kirupa.com/t/using-error-opening-url-as-a-variable/95647>\
**Category:** Uncategorized\
**Created:** [November 28, 2003, 5:49am UTC](https://forum.kirupa.com/t/using-error-opening-url-as-a-variable/95647 "2003-11-28T05:49:16Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![waffe](https://avatars.discourse-cdn.com/v4/letter/w/c37758/32.png) [@waffe](https://forum.kirupa.com/u/waffe)\
**Post date:** [November 28, 2003, 5:49am UTC](https://forum.kirupa.com/t/using-error-opening-url-as-a-variable/95647/1 "2003-11-28T05:49:16Z")

</div>

I have created my own dynamic photo gallery.

I have a loadmovie command with a url like this:

photo =“[http://www.domain.com/data\_base/gallery/"+photoNum+".jpg](http://www.domain.com/data_base/gallery/%22+photoNum+%22.jpg)”;  
screen.loadMovie(photo);

As you can see I have a variable in my url called photoNum. This is a number and it increases by one as I hit a next button in my flash movie.

on (release) {  
screen.loadMovie(photo);  
photoNum = photoNum+1;  
}

All of this works as it should. My problem is when I have 30 photos in my gallery and I am viewing the last photo, photoNum = 30. I hit my next button and photoNum = 31, I get a blank screen. I am looking for a way to go back to the first photo when this happens, photoNum = 1. Can I take the error message that flash outputs and use it as a variable? Something like:

if(Error opening URL==true){  
photoNum =1  
}

I have some other ways that will probable working using things like onData and a timer. If onData is not invoked after 5 sec, photoNum = 1. This way is to slow. Can my idea work or is there a better way altogether?
