Jump to content
GreenSock

Search In
  • More options...
Find results that contain...
Find results in...
failure13

Trouble with DataLoader

Recommended Posts

I am trying to re-write my old gallery code based on LoaderMax, so i've runned into some mad memory trouble, and just hope that this is my mistake...

The fragments of code here i will provide, searching for availible files in specifide folder, by counting numbers and replacing ## with numbers, i really love this concept, and with my old code i had no trouble, it have used 80mb with my test image folder, but now when i have rewritten it for DataLoader it eat 350mb, which have just shocked me! :D

 

Here's my new code with DataLoader:

// create an array of URLs

var imagesURL:Array = [];
// single item URL that will be written inside an array
var currentURL:String;
// counter for current URL
var currentNum:int = 0;

// function that loads next URL until it fails to find valid combination
function loadImagesURL():void {
// load next URL index
currentNum++;
// current URL pattern, that replaces ## in pattern for a numbers
currentURL = pattern.replace("##", currentNum);
// create new loader that loads new URL on complete and stops on I/O error (when there are no URL availible)
var loader:DataLoader = new DataLoader(currentURL, {onComplete: onNextComplete, onIOError: onNextError});
// load currentURL inside new loader
loader.load();
}

// function that adds URL inside an array
function onNextComplete(e:LoaderEvent):void {
// add current URL inside an array
imagesURL.push(currentURL);
// load next URL
loadImagesURL();
}

// function that stop searching for images when there are no URL availible
function onNextError(e:LoaderEvent):void {
// start listen for keys
stage.addEventListener(KeyboardEvent.KEY_DOWN, reactToArrowKeys);
// set up buttons array
for (var i:int = 0; i < galleryButtonsArray.length; i++) {
	// add listeners for previous / next click
	galleryButtonsArray[i].addEventListener(MouseEvent.CLICK, imageButtonsActions);
}
}

 

Here's my old code with native loader:

// function that loads next URL until it fails to find valid combination
function loadImagesURL():void {
// load next URL index
currentNum++;
// currentURL that replace ## in pattern for a numbers
currentURL = pattern.replace("##", currentNum);
// create new loader
var loader:Loader = new Loader();
// load currentURL inside new loader
loader.load(new URLRequest(currentURL));
// continue to load next URL inside an array
loader.contentLoaderInfo.addEventListener(Event.COMPLETE, onNextComplete);
// if loader fails, than execute onNextError function
loader.contentLoaderInfo.addEventListener(IOErrorEvent.IO_ERROR, onNextError);
}

// function that adds URL inside an array
function onNextComplete(e:Event):void {
// add current URL inside an array
imagesURL.push(currentURL);
// load next URL
loadImagesURL();
}

// function that stops when there are no other URLs
function onNextError(e:IOErrorEvent):void {
// start to listen for keys
stage.addEventListener(KeyboardEvent.KEY_DOWN, reactToArrowKeys);
// set up buttons array
for (var i:int = 0; i < galleryButtonsArray.length; i++) {
	// add listeners for previous / next click
	galleryButtonsArray[i].addEventListener(MouseEvent.CLICK, imageButtonsActions);
}
}

 

Hope that there are some obvious error i missed...

This is just a fragment of a huge gallery code, but since my testing gone - the problem in this part...

Link to comment
Share on other sites

Oh yeah, besides also when i try to simulate download speed lower than 200 kb/s i got an error all over the place, and nothing happen after:

TypeError: Error #1009: Can not access a property or method with reference to the object "null".

at _fla::MainTimeline/loadComplete()

Link to comment
Share on other sites

It sounds like you have some errors in your code somewhere else (not the part you shared) and it's pretty difficult to troubleshoot blind. Ideally, it'd be SUPER helpful if you could provide a set of files that we can publish on our end to clearly see the issue at play, plus an identical set that utilizes the old method (no DataLoader) so that we can verify for ourselves that the only thing that changed was the loader. Publishing it on our end is a critical component of being able to effectively troubleshoot.

 

By the way, the error seems to indicate that you've got some code inside your loadComplete() method that is trying to get a property or method of a null object.

Link to comment
Share on other sites

Thing is that i don't got no function called loadComplete, so it's must be gs onComplete call, or some internal flash stuff i belive...

 

Well, don't you mind if i'll post it in your PM, not on forum?

I can do my old file with that fragment of code, so you can see that even if you change nothing in there - it will make ~350mb out of ~80 real...

Or i can post my new code, where i rewritten already a lot of stuff...So you can try to eliminate this problem, and probably will look on anything else suspicious...

But i'm pretty much sure that this is that fragmetn of code..

Link to comment
Share on other sites

No, that error is definitely not inside any LoaderMax-related file - it says MainTimeline/loadComplete() which means you have a function named loadComplete on your main timeline somewhere (on a frame). (Not to mention the fact that there is no method named loadComplete() in any of the LoaderMax class files)

 

You can PM me, but please don't send huge files like that if you can possibly avoid it. Instead, just try to recreate the issue in a separate stripped-down FLA. That can really help you identify issues on your own too. Just start with the basics and then build up until it breaks and then you'll know exactly where the error is creeping in. See what I mean?

Link to comment
Share on other sites

Hmmm...Sorry, i found it, on other frame...Strange thing that without the gallery code - i never got this is error here...That's why i thought it's only gallery related function..

 

So this function is a main preloader for whole project

/////////////////////////////////////////////////// PRELOADER /////////////////////////////////////////////////

// stop and go fullscreen on start
//stop();
stage.displayState = StageDisplayState.FULL_SCREEN;
// reset logo alpha on start
intro.mainLogo.alpha = 0
// start listen for loading progress
this.loaderInfo.addEventListener(Event.COMPLETE, loadComplete);
this.loaderInfo.addEventListener(ProgressEvent.PROGRESS, loadProgress);

// function that defines actions on progress
function loadProgress(e:ProgressEvent):void {
var preLoaderPercent:Number = (e.bytesLoaded / e.bytesTotal) * 0.5;
// while progress, change logo alpha up to 0.5
TweenMax.to(intro.mainLogo, 0.5,{alpha: preLoaderPercent});
}

// function that defines actions on complete
function loadComplete(e:Event) {
// load complete - remove listeners and continue
this.loaderInfo.removeEventListener(Event.COMPLETE, loadComplete);
this.loaderInfo.removeEventListener(ProgressEvent.PROGRESS, loadProgress);
// logo appears fully from alpha = 0.5
TweenMax.to(intro.mainLogo, 1.2,{alpha:1, onComplete:intro.gotoAndPlay, onCompleteParams:["intro start"]});
}

Strange that i never got this error while testing lower speed before..

Any ideas how i should rewrite this fragment?

Probable with gs SelfLoader?

 

About simplifying, sorry, but i can't really simplify it right now...

But the only thing to check here is the gallery code, and this preloader, so this won't give you a lot of trouble, other than gallery code..

Link to comment
Share on other sites

Judging from that code, I'd bet that "intro" is null when that function gets called and that's what's throwing the error. I don't see where/how you're setting "intro" but it must be somewhere outside that function and you're assuming it gets set before that function gets called.

Link to comment
Share on other sites

Well it would be strange if it null, coz intro movieClip is on 1st frame, content layer, so i think it couldn't ever be null, no...?

But weirdest thing, is that if you test it with low speed, you will get this error after the loader succesfully fades in, and everythging is loaded except gallery...

So it should be somehow connected with gallery i guess. probably it is something wrong with those two?

this.loaderInfo.addEventListener(Event.COMPLETE, loadComplete);

this.loaderInfo.addEventListener(ProgressEvent.PROGRESS, loadProgress);

 

Maybe they somehow iterference with DataLoader's listeners when gallery loading?

I'm kinda lost in guess...

 

The idea was simply just to pre-load and show progress as intro.mainLogo alpha from 0 up to 0.5, and then from 0.5 to 1 just tween on loader's complete..

Link to comment
Share on other sites

I can't imagine it would choke on this.loaderInfo, but why don't you add a trace() in there for each suspected null object to find out for sure which one it is?

Link to comment
Share on other sites

I can confirm that it is indeed "intro" that is null (I added a trace() to confirm). I haven't had time to read through all the other code and analyze your setup to determine why exactly it's null but it might be because that asset is still loading (and hasn't instantiated yet) when the function gets called. Or it could have something to do with a scope issue caused by nesting functions within functions (I noticed you're doing that, but it is definitely frowned upon in ActionScript because it can cause gc issues and/or other timing errors because nested functions are typically deleted as soon as the parent function finishes). I hope that at least nudges you in the right direction for now.

Link to comment
Share on other sites

Yeah, this morning i've traced it too...Pretty weird.

 

Oh crap, i've just realised why it happens, i have commented out stop(); on 1st frame, just to skip intro for you, and of course if it's not stopped before preload it will throw all kind of errors when gallery loading on low speed! :D

Hell, i'm really sorry, it's hard to keep all details collecte, when simplifying in such a project..

 

Well anyway, this little issue is solved, but actual problem with memory is harder, and i can't solve it without your knowledge of gs...

I'm afraid that it will be something like this little stupid stop() issue, if i'll try to simplify the code to needed state, so if you would check just few functions in the lines i specified in last mail, it would be more fail-safe, i'm sure...

 

There are actually just few things to know, i got 3 loaders:

1) DataLoader to find image URLs in runtime through pattern.

2) XMLLoader to load xml with notes (if there are any of them)

3) ImageLoader to load image 1 by 1, not all at once or queue, just one at a time (at least that was a concept, but it seem that now all pictures loading memory).

 

Just take a simple test, as i do...Pick a #NEW.fla for the test. It's default memory consumption now is ~62,4Mb.

Note that all the test i've done belove was not in fullscreen, first thing i do is press esc on start, coz memory use is a bit higher in fs:

1. 501 line function onNextComplete, comment out loadImage(e); on line 512

It means in my code, that ImageLoader will never be used upon gallery loading.

That way if you'll measure memory it will be ~56,5Mb. This is perfectly fine, coz 1st image is 3,66Mb, so it's lower than default consumption for almost single picture weight, so this i guess will exclude problems with ImageLoader.

2. same function, comment out just textXML(e); line 514

It means that XML with notes won't ever be loaded. Memory consumption ~62,1Mb. Perfectly fair, so it's not the XMLLoader alone either.

3. Try to comment out both loadImage(e); and textXML(e);, to check if it's their combination.

Memory consumption will be ~56,2Mb, which again fair enough.

4. 497 line, loader.load();The only loader left is DataLoader, but in my code, if you'll comment it out it will be equal that all loaders are inactive. This way it will show 17,5Mb, which equal just the loaded project, without gallery embed code, so...I guess at least it clearly points out that DataLoader is the problem Loader in our case (well, or function)

 

So that narrows problem to functions that lays between lines 486 to 524, and probably their references of vars...Which is not that swampy, right? :)

This is the simpel test, that helps to narrow our search, and i guess it just can't be more narrow that that...

Link to comment
Share on other sites

I didn't follow your logic in step 4 - your DataLoader has an onComplete that calls onNextComplete() which is where you're creating the other loaders (via loadImage() and textXML()), so it would make perfect sense that if you eliminate the DataLoader (with its onComplete), then it would act like none of the other loaders are getting created. Right? Or am I missing something? I'm just really struggling to see where the logic is falling apart or why you think DataLoader is causing memory problems.

 

Is the problem maybe that you're preloading all of the images whereas with your old setup, you only loaded one at a time and dumped the previous one before you loaded the next? That would certainly explain the difference in memory usage.

Link to comment
Share on other sites

I didn't follow your logic in step 4 - your DataLoader has an onComplete that calls onNextComplete() which is where you're creating the other loaders (via loadImage() and textXML()), so it would make perfect sense that if you eliminate the DataLoader (with its onComplete), then it would act like none of the other loaders are getting created. Right?

Yeah, right!

I'm just really struggling to see where the logic is falling apart or why you think DataLoader is causing memory problems.

1. Coz even if we exclude step 4 which i'm thinking now as useless - it is only loader left of those 3..

2. In my original code if you will add loader.dispose(true); for function onNextError it will reduce memory consumption on like 50% (but only after you press next / previous to reload it). So when you dispose DataLoader at least it lower the memory consumtion a lot...But this doesn't seem to be a solution.

I think i misunderstood the concept somehow, i want DataLoader & ImageLoader to be created once, and then just use it with different input...As if it would be that only thing that is changing is URL for ImageLoader, something like if it would've been created even outside function loadImage, and inside this function i would just specify like loaderImages.load(imagesURLreq);

But i kinda suspect that each time it actually create a new loader...Which would expect memory-hunger, both for DataLoader & ImageLoader, but not for XMLLoader, coz it use physically one URL and one object...So it would pefrectly make sense, right? Any ideas how i should rewrite my loaders than?

 

Is the problem maybe that you're preloading all of the images whereas with your old setup, you only loaded one at a time and dumped the previous one before you loaded the next? That would certainly explain the difference in memory usage.

Well, according to memory It looks like this, but logic is exactly the same as with previous code, you can look on #OLD.fla file..

It still should load one at a time, according to my knowledge of as3, but i'm totally not sure about my gs Loader knowledge, so probably it is my mistake while making loaders...

Do you think that #NEW.fla loads more than one picture at a time now on start (as far as the code and loaders logic goes, not thinking of memory)?

Link to comment
Share on other sites

Yes, your current code is creating multiple loaders and loading them all initially. You have a circular reference going on - loadImagesURL() creates (and loads) a DataLoader that has an onComplete which calls onNextComplete(). That function also calls loadImagesURL(), so they keep going in a circle until finally a URL is invalid (once currentNum hits 8 in the example you sent me).

 

See what I mean?

 

To answer your other question, yes, you could create a single ImageLoader (or any loader) and simply alter its url whenever you want to load a new asset with the same instance, but that will unload the previous content (maybe that's what you want). Don't forget to call load(). But one of the big benefits of the whole LoaderMax platform is that it allows you to preload things easily so that the user doesn't need to wait for subsequent loads as much. Of course you're welcome to architect your project however you please.

 

As far as rewriting all that code for you, unfortunately we don't typically provide that kind of service for free here in the forums. If you had some very basic code, we'd surely dive in and help, but the file you sent has over 1,000 lines of code (I know only a portion of which deals with loading, but it can be difficult to isolate things accurately when there's a lot of other stuff going on in the file that might or might not affect the loading behavior). We'd also need to make sure we understand EXACTLY what you want and how things are supposed to work before we rewrote any code. Since you know your project so well, it may seem like it's a simple task to just dig in and rework the loading code, but without really digging in and spending a good chunk of time digesting the various pieces you have in place and mapping out the logic you desire (since the current stuff isn't working properly), it's not nearly as obvious to me. If you'd like to create a separate isolated FLA that only has some basics in place and you'd like our input, feel free to post it.

 

If you'd like to see a working example of a slide show, you can download some source files at http://www.greensock.com/as/LoaderMax/slideshow.zip. And there are some other learning resources at http://www.greensock.com/learning/ (scroll down to LoaderMax).

 

Oh, and I wanted to again reiterate that using nested functions is generally considered a bad idea in ActionScript, so my advice would be to avoid them.

Link to comment
Share on other sites

Yes, your current code is creating multiple loaders and loading them all initially. You have a circular reference going on - loadImagesURL() creates (and loads) a DataLoader that has an onComplete which calls onNextComplete(). That function also calls loadImagesURL(), so they keep going in a circle until finally a URL is invalid (once currentNum hits 8 in the example you sent me).

 

See what I mean?

Well kind of, but in that case, what is the syntax to make this?

To answer your other question, yes, you could create a single ImageLoader (or any loader) and simply alter its url whenever you want to load a new asset with the same instance, but that will unload the previous content (maybe that's what you want).

In this case that is exactly what i want, how would i alter the url for the existing loader?

 

And please man, i hear you clear from 1st time, i am not asking you to rewrite code, or especially rewrite code not for free...

What i'am asking is just to look on specific functions in this mess, and help me with syntax of gs Loaders, coz i'm not yet familiar with them on 100%...

I was checking those links already, but as you can see my whole concept is a bit different (and i like the idea), it have worked nice with my previous code, just coz i used to create vars with lodaers outside the functions, but in this case i didn't know how to load outside gs loaders with specifing new URL parameter, that's all...

Oh, and I wanted to again reiterate that using nested functions is generally considered a bad idea in ActionScript, so my advice would be to avoid them.

I heard you...But why's that? I mean it's exactly same as classes, and i freaking hate class-written projects aproach, coz you have to import each time all the necessary stuff for flash, you have to write all of those private attributes, a lot of junk that really just narrows my thinking too much...

So i would like to keep it that simple (in my opinion) way, coz so far i haven't got on a big trouble yet...

Link to comment
Share on other sites

Regarding the nested functions comment, I didn't mean to imply you needed to shift your whole workflow to use classes and object-oriented concepts. Not at all. I simply meant this:

 

//BAD: 
function func1() {
   ...
   function func2() {
    ...
   }
}

//GOOD: 
function func1() {
   ...
}
function func2() {
   ...
}

 

As for changing the URL for a particular loader, it is as simple as changing the url property:

myLoader.url = "myNewURL";

 

As far as rewriting the code, I know you're not trying to be rude or make someone else do your work. No worries. It's just that I can tell by looking at it that we think very differently, so I'd probably re-architect things at a very foundational level if I were to tackle this. Not that I'd use classes per se, but it would be kinda like if I asked you to rewrite 100 lines of code that were contained in 6 different classes. You'd probably redo things in a procedural manner on the timeline because that's how you think and it wouldn't be as simple as tweaking a couple of things in the class files. If you have a specific question about how to do something with the GreenSock classes, we'd be happy to help.

 

The concept of the LoaderMax loaders is pretty much the same as a regular Loader except that there are a bunch of extra conveniences and efficiencies. So the code flow doesn't need to be very different compared something you had working previously with regular Loaders. Create your instance, add an onComplete listener, load(), etc. Again, we're happy to answer any questions specific to the GreenSock tools.

Link to comment
Share on other sites

As for changing the URL for a particular loader, it is as simple as changing the url property:

Well...Seem that it's not that simple :D

 

I've changed this two things, as you said, like i've created global ImageLoader, and inside loadImage function i've just specified .url and then simply load loader...But for some reason nothing got displayed (no mistakes reported either)...What am i doing wrong?

 

// loader for images
var loaderImages:ImageLoader = new ImageLoader("", {
   name: "loaderImages",
   container: images,
   x: 0, y: 0,
   width: gW, height: gH,
   scaleMode: "proportionalInside",
   onComplete: loadImageNow
});

// function that loads an image
function loadImage(e:Event):void {
   // define image URL
   loaderImages.url = imagesURL[index];
   // load image with loader
   loaderImages.load();
}

 

Just try to change those little things in my new code, i'm sure you will understand what mistake i've made...

 

Regarding the nested functions...Well, but in this case, according to your logic, this meant to be bad:

// create new gallery instance
var gallery3:MovieClip = addGallery(
   contentWidth, contentHeight,
   divLeft, divRight,
   divUp, divDown,
   "system/gallery/visualization1/visual##.jpg"
);

// position gallery
gallery3.x = 0;
gallery3.y = 0;
// name and add gallery on stage
gallery3.name = "gallery3";
addChild(gallery3);

function addGallery(gW, gH, imgLimitL, imgLimitR, imgLimitT, imgLimitD, pattern:String, XMLpath:String=""):MovieClip {
   ...
   function func1() {
       ...
   }
   function func2() {
       ...
   }
   ...
   return something
}

 

Right? But then i simply can't live without such an aproach, coz this is my way of implementing multiple instances...

And also i got next question then...

// BAD
function textXML(e:Event):void {
       var galleryXMLLoader:XMLLoader = new XMLLoader(XMLpath, {name: "galleryXMLLoader", onComplete: processGalleryXML});
       galleryXMLLoader.load();
       function processGalleryXML(e:LoaderEvent):void {
           galleryXML = new XML(e.target.content);
       }
}

// GOOD
function textXML(e:Event):void {
       var galleryXMLLoader:XMLLoader = new XMLLoader(XMLpath, {name: "galleryXMLLoader", onComplete: function() {galleryXML = new XML(e.target.content);} });
}

Is this statement right, and good doesn not counts as faulty nested function logic?

 

Well...And yeah, of course we think differently, so no worries :)

I'am trying to make it simple for you to help me, as far as i can...

Here i come of course for gs questions, not to waste your time too much...

It's just sometimes as3 can get very very frustrating, and you're an expert, so chances you'll say what exactly fails gs or flash - are very high also!))

Link to comment
Share on other sites

I tried patching your new code into the old file you sent me and it seemed to work (I saw the image load on the stage) so I'm really not sure what is causing the problem on your end. Like I said, it is very difficult to troubleshoot in a file like this - it is MUCH cleaner if you just create a very simple (separate) FLA that only has the relevant code for the particular issue we're looking at and then post it so that we can publish and see what's happening.

 

As for the nested functions, I don't want to cause you a bunch of discomfort with the approach you're used to. If it's working for you, go for it. I'd definitely encourage you to consider using classes and a more object-oriented approach eventually because ultimately I think it'll serve you better and create a more organized structure which makes working on complex projects far easier.

 

The anonymous function in your 2nd example is okay, but even anonymous functions have been discouraged in ActionScript. Yes, they work - just kinda frowned upon. They can create garbage collection headaches and you can paint yourself into a corner and find yourself needing to reference a function but there's no way to do it when it's anonymous. But again, if it's working for you I don't want to add to your frustration by shoving you out of your comfort zone too much :)

Link to comment
Share on other sites

Wow...I'm kinda amazed, i've just try to make fast changes for the #NEW.fla i've sent to you, and what i found - it works and display everything, just as you said...

 

But then i realized the difference, in my original code i've put var loaderImages before var images:MovieClip = new MovieClip();, so it haven't got chance to know what is container: images, right?

Well, it seem to work, now i'll try to rebuild DataLoader this way, and will report my memory results..

 

And you're definately not first and not the last who have recommended me to switch for object-oriented aproach, but it's definately just not my thing... :)

But who knows, probably some day, when i'll do some insanely hard and big project...))

Link to comment
Share on other sites

I got an amayzing results now, thank you sooo much for help!!!!

It's almost equal to one single loaded image, so whole gallery is not memory stressing at all!!

 

Just one last question before this thread would be completely solved, when i press next / previous buttons or left / right arrows, i am doing this:

function reloadNewImage():void {
	if (loaderImages != null && contains(images)) {
		// each time next or previous button pressed - unload and remove images from screen
		loaderImages.unload();
		// load new image, depend on which button was pressed
		loadImage(e);
	}
}

 

Is it correct? I call loaderImages.unload(); to unload previous picture, and then call loadImage(e); to load new one, with just passing new URL parameter for loader. I am not sure coz your methods always called dispose, so just for syntax sake...

And if (loaderImages != null && contains(images)) do i need to check contains(images), withgs loader's logic, or it is unnecessary now?

Oh, and i used , format: "binary" in DataLoader at some point, for experimenting, but do i need to keep it so in my case, or should i just delete this line?

 

Again, thx for your help and patience, i got deep respect for your care & support!

Link to comment
Share on other sites

I don't know if that's correct because I don't know what "e" refers to, nor am I familiar with exactly what you're attempting to do or how you intend for the various methods to work together. If you have a specific question about LoaderMax, I'd be happy to answer that. Or if you want to post an example FLA that we can publish so that I can see the code in context, I'd be happy to take a peek.

 

There's no reason to check whether or not the image is in any particular DisplayObjectContainer as far as LoaderMax is concerned, so don't do contains(images) unless your code relies on it.

 

As far as the format:"binary" for DataLoader, I'm not even sure what you're trying to do with the DataLoader in the first place so I don't know if you need to delete that line. If you're simply loading images with ImageLoader, there's no reason to have any DataLoader instances at all.

Link to comment
Share on other sites

I meant, is it correct to loaderImages.unload(); to just unload picture from loader and do nothing more?

 

DisplayObjectContainer as far as LoaderMax is concerned, so don't do contains(images) unless your code relies on it.

Ok...What i wanted in this part, with my previous code, is just to ensure that after you press button, you will unload previous image, and load new only if something is already inside loader, but i believe you said somewhere, that if you just load image with ImageLoader, you don't have to call for unload first, it will automatically unload everything for you (even if it's not fully loaded also?), is it right?

As far as the format:"binary" for DataLoader, I'm not even sure what you're trying to do with the DataLoader in the first place so I don't know if you need to delete that line. If you're simply loading images with ImageLoader, there's no reason to have any DataLoader instances at all.

It's easy what i'am doing, just not so many people do it...

I pass URL string like this "system/gallery/patr/picture##.jpg", and then DataLoader changes ## for numbers and write

each valid url inside an URL array (which i use to switch between pitctures), until it fails...

I know you thought that this is kinda crazy and probably slow, but why not, since it's projector standalone .exe project?) I think it's kinda cool way to just rename your pictures, and don't even waste your time editing xml..

 

So, to shorten it out, basicly what DataLoader doing in my case, is simply checking if file name really exists...Is there any better / faster way to do this without actual loading something in ram?

What i need is just to check if URL really exists, and if not do something, but now it's loading content of url of course

Link to comment
Share on other sites

I meant, is it correct to loaderImages.unload(); to just unload picture from loader and do nothing more?

Yes.

 

Ok...What i wanted in this part, with my previous code, is just to ensure that after you press button, you will unload previous image, and load new only if something is already inside loader, but i believe you said somewhere, that if you just load image with ImageLoader, you don't have to call for unload first, it will automatically unload everything for you (even if it's not fully loaded also?), is it right?

Yes.

 

It's easy what i'am doing, just not so many people do it...

I pass URL string like this "system/gallery/patr/picture##.jpg", and then DataLoader changes ## for numbers and write

each valid url inside an URL array (which i use to switch between pitctures), until it fails...

I know you thought that this is kinda crazy and probably slow, but why not, since it's projector standalone .exe project?) I think it's kinda cool way to just rename your pictures, and don't even waste your time editing xml..

 

So, to shorten it out, basicly what DataLoader doing in my case, is simply checking if file name really exists...Is there any better / faster way to do this without actual loading something in ram?

What i need is just to check if URL really exists, and if not do something, but now it's loading content of url of course

That's fine to do, but I still don't understand why you use a DataLoader first ,and then you use an ImageLoader to basically do the same thing. Why not just use an ImageLoader in the first place? That way you're using half the memory and making half the requests.

Link to comment
Share on other sites

That's fine to do, but I still don't understand why you use a DataLoader first ,and then you use an ImageLoader to basically do the same thing. Why not just use an ImageLoader in the first place? That way you're using half the memory and making half the requests.

Well...That's a good question actually, but it's also hard one for my understanding also...

I mean, for example, if dataLoader after doing his job have loaded memory THAT hard (and i still have to dispose of it, after it's finished to unload his part from memory), than how much ImageLoader will eat...Well, probably i just miss your question concept, could you provide fast example piece of what you mean?

 

As i understood, in this way, i'll have to check all the urls with image loader, than dispose it (just to unload all the memory that was full-filled with fast url check, which equal almost whole folder weight), and then load it with single needed url, did i get it right?

Well, technically it's just the same i guess...

But, is there a way to check urls availibility without loader?

My goal in the first place is just to make an array of urls, with this automated method, but as you can see it's not really perfect...

Link to comment
Share on other sites

Well...That's a good question actually, but it's also hard one for my understanding also...

I mean, for example, if dataLoader after doing his job have loaded memory THAT hard (and i still have to dispose of it, after it's finished to unload his part from memory), than how much ImageLoader will eat...Well, probably i just miss your question concept, could you provide fast example piece of what you mean?

There is no significant difference between DataLoader and ImageLoader in terms of memory. Loading is loading. Let's say you have a 100kb image that you're going to load. Currently, you're loading that first into a DataLoader (+100kb memory), then you're creating an ImageLoader and loading the SAME image (+100kb, for a total of 200kb). Why not simply load with an ImageLoader initially? That'll save 100kb in this example, plus it'll use only one request rather than 2 (1 for DataLoader, and another for ImageLoader). It's fine if you unload() the ImageLoader later when you don't need it and then load() again when you do. Do that as many times as you want.

 

As i understood, in this way, i'll have to check all the urls with image loader, than dispose it (just to unload all the memory that was full-filled with fast url check, which equal almost whole folder weight), and then load it with single needed url, did i get it right?

Well, technically it's just the same i guess...

But, is there a way to check urls availibility without loader?

My goal in the first place is just to make an array of urls, with this automated method, but as you can see it's not really perfect...

Technically you could create a URLStream (which is from Adobe and has nothing to do with LoaderMax) and start loading a URL and then as soon as it either dispatches a PROGRESS event or fails, you know whether or not the file is there and you can cancel the load immediately. That way, if the file is there, it doesn't fully load. That's basically what the LoaderMax loaders to for file size audits, but you must be careful to append something to the URL so that it doesn't get cached, otherwise some browsers inadvertently use the partially-downloaded file from the cache as the real file and it gets corrupted (again, none of that has anything to do with LoaderMax). the ONLY benefit to doing it that way is you can do pure audits faster without actually loading the whole file (when one exists). I wouldn't really recommend it unless you know what you're doing, though. It's probably safer to just use the stock LoaderMax loaders because they automatically shield you from a bunch of bugs/headaches related to the raw AS3 loader stuff from Adobe.

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×