PDA

View Full Version : some weird error after thumbs load driving me crazy



werehunt
May 21st, 2009, 04:24 AM
not weird in a sense i have never seen it, but after hours of debugging i really dont understand why its happening..

here is my setup (needed for understanding the problem):

i am placing thumbs on the stage in a grid and i have few categories of thumbs, by default first category loads, and then you can choose between other categories.

first of all, error doesnt happen if i dont simulate download

second, error doesnt happen if i simulate download and wait for all the thumbs to load before skippping to next category

error only happens if i simulate download and while current category (any of them) is loading, i skip to some other category
(call function clickCategory(e:MouseEvent):void) (line 104).

but the error doesnt happen there (during category switch), thumbs start loading just fine, it always happens after last thumb loads.

and in either case (error or not) all the thumbs load just fine, from first to last one, in sequential matter.

-----
here is the code: http://pastie.org/485074

yes, i know, its long, but the error comes from this function:

function thumb_Complete(e:Event):void (line 76)

i have 2 things here: adding the thumb and removing the movieclip preloader (which is a sppining animation)

in this case, removing preloader on line 91 causes an error, but preloader is there, i can trace it just fine (and like i said, it works (no error) when i dont simulate download, or wait for all the thumbs to load before switching to next category, so the code must be right)

i dont get it i have been debugging this for hours and i am completely out of clue why is that happening...

ofeet
May 21st, 2009, 10:00 AM
just taking a quick look, don't have enough time to delve but-

does e.target point to thumbLoader? or the content of thumbLoader? I don't believe it points to the contentLoaderInfo

try

e.target.contentLoaderInfo.removeEventListener(IOE rrorEvent.IO_ERROR, thumb_IOError);
or
add your thumbLoaders to a private array on the class and then have the class clear the eventlisteners for you.

while(thumb_Loaders.length) {
var obj:Loader = thumb_Loaders.pop();
obj.contentLoaderInfo.removeEventListener(IOErrorE vent.IO_ERROR, thumb_IOError);
}

werehunt
May 21st, 2009, 10:50 AM
just taking a quick look, don't have enough time to delve but-

does e.target point to thumbLoader? or the content of thumbLoader? I don't believe it points to the contentLoaderInfo

try

e.target.contentLoaderInfo.removeEventListener(IOE rrorEvent.IO_ERROR, thumb_IOError);

ReferenceError: Error #1069: Property contentLoaderInfo not found on flash.display.LoaderInfo and there is no default value.
at MethodInfo-110()