PDA

View Full Version : onData jpg


jerryj
06-19-2005, 04:39 PM
Hi,
I am loading jpg's, and I want to make a Movieclip('MC') invisible when there is no jpg to load (because it just is not there). How can I detect if there is no jpg, and then make the MC invisible? I think I should use onData, but I can't make it work.

function laadNail3(foto) {
var my_lv:LoadVars = new LoadVars();
my_lv.onData = function(src:String) {
if (src == undefined) {
MC._visible = false;
}
foto = src;
};
my_lv.load(foto, holder);
}
I am also confused where to put the Movieclip that holds the jpg ('holder')?

The data passed to the function comes from another swf, saying:

laadNail3("b3.jpg");

Could someone show me how to do this?

thank you,

Jerryj.

DoctorDigital84
06-20-2005, 12:38 AM
i too have been working with loading pictures, and it makes a mess when they don't exist. My solution was to make an external text doc that I manually edit to tell the number of images to load.

Another attempt was to try to load it, and then check the height or width, but it was possible it could check the height or width before the image had loaded from the net, whether it existed or not, so it always said it wasnt there.

I know in the newer versions of flash there are ways to detect if a load fails(correct me if i'm wrong), but that was more work than i have time for right now.

hope this helps or gives you comfort that someone else is in the some struggle :cool:

jerryj
06-20-2005, 07:00 AM
I think I got it:
mcC1._visible = false;
function laadNail3(foto) {
NF3MC.loadMovie(foto);
var temp = this.createEmptyMovieClip("temp", 116);
temp.onEnterFrame = function() {
if (NF3MC.getBytesTotal() == NF3MC.getBytesLoaded() && NF3MC.getBytesTotal()>4) {
mcC1._visible = true;
}
};
}

It seems to work (thanks to Scotty by the way),

good luck,

Jerryj.

jerryj
06-27-2005, 04:04 PM
mm, my last remark seems off the mark, that is not going to make it work.

So I still have the same problem. Is there a way to make something happen when there are no kB's/data loaded, because there is no jpg online that the loadMovie is referring to?
Within my code:
function loadFotoNieuws(clip, txt, a, b, c) {
NFMC.loadMovie(clip);
var temp = this.createEmptyMovieClip("temp", 112);
temp.onEnterFrame = function() {
if (NFMC.getBytesTotal() == NFMC.getBytesLoaded() && NFMC.getBytesTotal()>1) {
makeArtikel(txt, a, b, c);
this.createEmptyMovieClip("border", 6);
this.border.lineStyle(1, 0x000000, 100);
this.border.lineTo(NFMC._width, 0);
this.border.lineTo(NFMC._width, NFMC._height);
this.border.lineTo(0, NFMC._height);
this.border.lineTo(0, 0);
this.border._x = 320;
this.border._y = 240;
} //HERE I WOULD LIKE TO MAKE SOMETHING LIKE:
//IF NO DATA ARE BEING LOADED, DO:
NFMC.loadMovie("ad1.swf");
this.border._visible = false;
makeArtikel(txt, a, b, c);
}
delete this.onEnterFrame;
};
}

It would be great if someone could tell me the answer (can't be that hard!)

Thank you,

Jerryj.

jerryj
06-27-2005, 04:15 PM
Did another search and it seems to be impossible, except when you use a server side script like php, see for instance:
link (http://www.flashkit.com/board/showthread.php?threadid=392721&highlight=check+file+exists)

deadbeat
06-27-2005, 05:42 PM
If you use the MovieClipLoader class, you can use the onLoadError event:

http://www.macromedia.com/livedocs/flash/mx2004/main_7_2/wwhelp/wwhimpl/common/html/wwhelp.htm?context=Flash_MX_2004&file=00001579.html#wp4001138

K.

jerryj
06-27-2005, 07:25 PM
thanks deadbeat,

just what i needed.

Jerryj.