Share Posted June 23, 2014 I am using the LoaderMax to help load in an XML doc that contains image paths, other data, etc... Gallery functions great! Love it. You guys ROCK! My question is, to advance this I want to have my gallery reload the xml doc every few hours. To account for any changes etc... To do this in the background while it is currently playing is some what understandable… However, I have been going back and forth with toggling the Loaders or at a certain interval create a new xmlLoader and grab new data. Once everything is loaded, toggle the list. ??? I went through the docs after someone suggested calling "load(true)" on the xmlLoader instance, but that resulted in wiping. Another suggestion was to append then remove old but that seemed tedious. Any help is much appreciated…. I will continue to look through the forums. Thanks! -mt Link to comment Share on other sites More sharing options...
Author Share Posted June 23, 2014 Ooops forgot to add some code… I guess where it would make sense would be to check for count within the managePlayBack function if the counter reaches a certain point…. private function getPlayList():void { xmlLoader = new XMLLoader(urlStr, {name:"xmlDoc", onProgress:progressHandler, onComplete:completeHandler, onError:errorHandler}); xmlLoader.load(true); } private function completeHandler(event:LoaderEvent):void { xmlLoader.removeEventListener(LoaderEvent.COMPLETE, completeHandler); xmlLoader.removeEventListener(LoaderEvent.ERROR, errorHandler); xmlLoader.removeEventListener(LoaderEvent.PROGRESS, progressHandler); media = LoaderMax.getLoader("media"); media.addEventListener(LoaderEvent.COMPLETE, mediaCompleteHandler); media.addEventListener(LoaderEvent.ERROR, errorHandler); media.addEventListener(LoaderEvent.PROGRESS, progressHandler); media.load(); } private function progressHandler(event:LoaderEvent):void { //trace("progress: " + event.target.progress); } private function errorHandler(event:LoaderEvent):void { if(event.target is XMLLoader) { xmlLoader.removeEventListener(LoaderEvent.COMPLETE, mediaCompleteHandler); xmlLoader.removeEventListener(LoaderEvent.ERROR, errorHandler); xmlLoader.removeEventListener(LoaderEvent.PROGRESS, progressHandler); } else { media.removeEventListener(LoaderEvent.COMPLETE, mediaCompleteHandler); media.removeEventListener(LoaderEvent.ERROR, errorHandler); media.removeEventListener(LoaderEvent.PROGRESS, progressHandler); } } private function mediaCompleteHandler(event:LoaderEvent):void { media.removeEventListener(LoaderEvent.COMPLETE, mediaCompleteHandler); media.removeEventListener(LoaderEvent.ERROR, errorHandler); media.removeEventListener(LoaderEvent.PROGRESS, progressHandler); if(ini==false) { ini = true; TweenLite.to(intro, .5, {alpha:0, onComplete:removeIntro}); } } private function removeIntro():void { managePlayer(); removeChild(intro); intro = null; } //Counter for how many times through private var playbackCnt:int = 1; private function managePlayBack():void { //if playlist is complete if(mediaTracker==media.numChildren) { //inc up playbackCnt++; trace("playlist complete "); //setTracker back mediaTracker=1; if(playbackCnt==50) { trace('Lets do something here and check for new data'); } managePlayer(); } else { mediaTracker++; managePlayer(); } } private function managePlayer():void { var currAsset = media.getChildAt(mediaTracker-1); if(currAsset.vars.type!=null) { if(currAsset is ImageLoader){ container_mc.addChild(currAsset.content); TweenLite.to(currAsset.content, .5, {alpha:1}); TweenLite.delayedCall(currAsset.vars.time, fadeImageOut, [currAsset.content]); } } } private function fadeImageOut(obj):void { TweenLite.to(obj, .5, {alpha:0, onComplete:imageComplete, onCompleteParams:[obj]}); } private function imageComplete(obj):void { container_mc.removeChildAt(0); obj = null; managePlayBack(); } Link to comment Share on other sites More sharing options...
Share Posted June 24, 2014 Yeah, that's a non-trivial task. Don't really know what to suggest from looking at the nearly 100 lines of code you posted. There really isn't anything built into LoaderMax to accommodate loading new XML data and somehow comparing it to previous data you loaded. You say your xml contains image paths, not actual <ImageLoader> nodes so I don't know exactly how reloading the xml document is wiping anything out. In basic terms I think if you are loading a list of image urls you would keep track of how many images have been previously loaded and if the new xml file contains more images than that amount, you just pick off the new paths and append ImageLoaders to a LoaderMax that contains the rest of your ImageLoaders. Again, its not necessarily easy to do, and to offer the proper advice would take a deep study of your entire files and xml structure, which would take quite a few hours of testing. Link to comment Share on other sites More sharing options...
Author Share Posted June 24, 2014 Carl, Thanks for responding. My apologies, I am using <imageLoader> nodes and then within each our attributes for duration, title, etc... Since, I have tried unloading and loading again. Any other suggestions? Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now