Groups | Blog | Home
all groups > flash actionscript > march 2006 >

flash actionscript : Re: error -handling


LuigiL
3/30/2006 7:59:09 PM
Stubbern...

Try this:
Put an instance of the loader on the stage and give it an instance name
'loader'. Code on frame 1 (seperate layer):
try {
if(this.loader.contentPath="images/02.jpg"){
throw new Error("Image path incorrect");
}
} catch (e:Error) {
trace("Error: "+e.message);
} finally {
trace("Execute this code.");
}
hannus
3/30/2006 8:11:55 PM
LuigiL
3/30/2006 8:31:37 PM
var current:Number=0;
try {
if(this.loader.contentPath="images/0"+current+".jpg"){
throw new Error("Image path incorrect");
}
} catch (e:Error) {
trace("Error: "+e.message);
} finally {
current=1;
this.loader.contentPath="images/0"+current+".jpg";
}
hannus
3/30/2006 8:58:15 PM
And how would this help me in any way ? This only shows an image with the URL
images/01.jpg (in the final-clause), though it tries to open images/00.jpg
first, which will always fail because 1 is the first existing index. I know
that the 0 index can not be found but what is the OTHER boundary?
LuigiL
3/30/2006 9:15:57 PM
The original question:
[quoted text, click to view]
the catch block.
I've answered that - you need an if-statement there and throw an error.
Now, when I look at your code, you are adding 1 to a var on(click) and then
test if that particular image exists. If not, you reset the var to 1. So, your
code should read:
on (click) {
this._parent.current = this._parent.current+1;
try {
if(this._parent.dj_images.contentPath =
"d:/ia/test/timesheet/fotos/CarlCox"+this._parent.current+".jpg"){
throw new Error("Image path incorrect");
}
} catch (e:Error) {
trace("Error: "+e.message);
this._parent.current = 1;
this._parent.dj_images.contentPath =
"d:/ia/test/timesheet/fotos/CarlCox"+this._parent.current+".jpg";
} finally{
this._parent.dj_images.refreshPane();
}
}
AddThis Social Bookmark Button