Jump to content
Search Community

Ahrengot last won the day on August 23 2012

Ahrengot had the most liked content!

Ahrengot

Business
  • Posts

    60
  • Joined

  • Last visited

  • Days Won

    1

Everything posted by Ahrengot

  1. To clarify, the images themselves are being removed. I tried setting the alpha on loaded content to 0.5 and there are never 2 images above each other, but the ContentDisplay is left behind. the following traces: "[object SimpleGallery] Stuff left behind: [object ContentDisplay]" private function clearMainLoader():void { _mainLoader.unload(); _mainLoader.empty(); var i:int = _imageHolder.numChildren; trace(this + " clearMainLoader() found " + i + " children in _imageHolder. Removing them now."); while (i--) { //_imageHolder.removeChildAt(i); trace(this + " Stuff left behind: " + _imageHolder.getChildAt(i)); } }
  2. I think the following is a bug, as the documentation states that unload() on LoaderMax does the following: "Removes any content that was loaded ..." however the ContentDisplay classes is still kept in my container in the following example: I have a _mainLoader LoaderMax containing ImageLoader's. It's a simple gallery with next/previous functionality and when next/previous is called, the LoaderMax flushes it's content and a new image is loaded. However ContentDisplay instances aren't being removed from their container correctly. Setup of the loader, event handlers etc. - _images is an Array containing strings(url's to the images) public class SimpleGallery extends Sprite { // Images private var _images:Array; private var _index:int = -1; // Container private var _imageHolder:Sprite; // Loading private var _mainLoader:LoaderMax; public function SimpleGallery($images:Array) { _images = $images; addEventListener(Event.ADDED_TO_STAGE, init, false, 0, true); } private function init(e:Event):void { removeEventListener(Event.ADDED_TO_STAGE, init); addEventListener(Event.REMOVED_FROM_STAGE, destroy, false, 0 , true); _imageHolder = new Sprite(); addChild(_imageHolder); setupGallery(); } private function setupGallery():void { _mainLoader = new LoaderMax( { name:"mainLoader", auditSize:true, onChildProgress:handleProgress, onChildComplete:handleComplete, onError:handleErrors } ); loadNext(); } private function handleProgress(e:LoaderEvent):void { trace(this + " load progress: " + int(ImageLoader(e.target).progress * 100) + "%"); } private function handleComplete(e:LoaderEvent):void { trace(this + " Loader " + ImageLoader(e.target).name + " successfully loaded: " + ImageLoader(e.target).url); dispatchEvent(new Event(Event.CHANGE)); } private function handleErrors(e:LoaderEvent):void { trace(this + " ERROR loading on loader " + ImageLoader(e.target).name + " loading image: " + ImageLoader(e.target).url); } clearMainLoader method: private function clearMainLoader():void { _mainLoader.unload(); _mainLoader.empty(); var i:int = _imageHolder.numChildren; trace(this + " clearMainLoader() found " + i + " children in _imageHolder. Removing them now."); while (i--) { //_imageHolder.removeChildAt(i); } } Now, if i don't uncomment that '_imageHolder.removeChildAt(i);' line the content keeps piling up in _imageHolder. Next previous methods: /** * Loads the next image in the provided array */ public function loadNext():void { _index++ if (_index == _images.length) _index = 0; clearMainLoader(); _mainLoader.append(new ImageLoader(_images[_index], { container:_imageHolder } )); _mainLoader.load(); } /** * Loads the previous image in the provided array */ public function loadPrevious():void { _index-- if (_index == -1) _index = _images.length - 1; clearMainLoader(); _mainLoader.append(new ImageLoader(_images[_index], { container:_imageHolder } )); _mainLoader.load(); }
  3. Ahh that's right. I hadn't thought of that
  4. I don't know if i've overlooked a preexcisting way to do this (get raw loaded content by defining URL or loader name) Scenarios could be that i wanted to access methods, setters, getters etc. on my loaded swf's or controlling playback (gotoAndPlay(), gotoAndStop(), stop() etc.) since it's already a feature of the individual loaders i think it would make sense to add it to LoaderMax. Of couse i could just go like this: SWFLoader(_loadingQueue.getLoader("foo")).rawContent.myMethod(); but i think this is a little prettier: _loadingQueue.getRawContent("foo").myMethod(); Anyway, I hope my request makes sense
  5. Sorry i just thought about this now, but how about renaming the loop property in VideoLoader and MP3Loader to repeat and define it as an integer instead(where -1 = infinite repeat) - That way it would be consistent with the way loops are handled in TimelineMax and TweenMax.
  6. Great! that was fast How about deblocking? Also, there's an autoPlay property, i think it would make sense to add an autoLoop/loop property as well.
  7. I'm playing around with the VideoLoader now. It seems like a really cool add-on, and i like how you added basic playback control. It makes a lot of sense those methods are there, without making it too complicated for a loader class. This is really becoming a great asset management tool! I do have two feature requests though. Since there's a smoothing property in the vars object of the ImageLoader, wouldn't it make sense to add that along with deblocking to the vars object of the VideoLoader? btw, I love how you just made the following this easy: 1 - loading a video, setting up NetStream, NetConnection etc. etc. etc. 2 - fitting it proportionally, centered in a container 3 - Handling complete and error events var videoLoader:VideoLoader; videoLoader = new VideoLoader("assets/video/website.f4v", { container:this, width:stage.stageWidth, height:stage.stageHeight, scaleMode:"proportionalOutside", onError:handleErrors, onComplete:handleComplete} ); videoLoader.load();
  8. Thanks for that elaborate reply, Jack! Just to clarify, all i really need to do, to garbage collect my LoaderMax along with it's 100 ImageLoader's is to call the unload() method on my LoaderMax instance and nullify it like: _loaderMax.unload(); _loaderMax = null;
  9. Today is the first time i've got to play around with LoaderMax, and it really feels like a fantastic tool to work with. It's very intuitive and easy to wrap your head around if you're familiar with TweenMax and TimelineMax. I can't wait to get it completely under my skin, as it actually makes loading stuff fun, which is very bizarre to me Here's my question: Let's say i have a LoaderMax with 100 ImageLoader's nested inside of it and i want to keep everything running smoothly without memory leaks etc. Question 1: Unloading What excactly does LoaderMax.unload() do? The documentation states that the unload method does the following "Removes any content that was loaded and sets bytesLoaded back to zero." does that mean content in nested loaders? how about content nested in loaders nested in another loader? For instance, could i call .unload() on my LoaderMax containing 100 image loaders and expect they'd all unload without having to set up for loops or anything like that? Also, does .unload() cancel all current loaders or should i first call .calcel() and then .unload() if i want to abort all loading and destroy my LoaderMax instance? Question 2: The autoDispose feature Am i mistaken by thinking this is essentially a kind of remove-all-EventListeners method? It's turned off by default, but wouldn't i normally want my loaders to remove their listeners when they're done loading? Also, what happens if i forget to dispose of a loader when i'm done with it? Will it break my site/application or are those kinds of things handled?
×
×
  • Create New...