Jump to content
Search Community

overcoded

Members
  • Posts

    2
  • Joined

  • Last visited

overcoded's Achievements

0

Reputation

  1. After further research, the only way I could get this to work was to reinitialize my VideoLoaders like this: loaderArray[currentSlideIndex-1] = (new ImageLoader(url1, {name:"slide1", width:1920, height:1080})); Is there any better way to do this? If not I have a lot of code to refactor
  2. I'm having an issue loading loaders that have been loaded, then disposed of. Let me explain that (it gives me a headache trying to parse it). I have an array of loaders, some VideoLoaders, some ImageLoaders. I'm trying to make something where you can swipe through multiple objects, but rolled my own garbage collection so only three objects (previous, current, and next) are currently loaded into memory, as these files can get fairly large. I append a loader to my LoaderMax instance, then call the load() method. As I move forward through my array, I append the prev, current, and next loader based on my currentSlideIndex. I move forward two objects, then call loaderArray[currentSlideIndex-2].dispose(true) to unload the content of that particular loader. If I move backwards through the array, eventually, the first loader I appended will get appended to my LoaderMax instance a second time. LoaderMax doesn't seem to throw an error (although I don't believe I'm listening for one) and completes it's loading. When I try to access the content property, it is null. Any ideas how to load this content a second time or to change up my garbage collection? Here is some code to help explain it: var currentSlide:Sprite = new Sprite(); var previousSlide:Sprite = new Sprite(); var nextSlide:Sprite = new Sprite(); var currentSlideIndex:int = 0; var loaderArray:Array = new Array(); var presentationLoader:LoaderMax = new LoaderMax({onComplete:doneWithCurrentLoad}); loaderArray.push(new ImageLoader(url1, {name:"slide1", width:1920, height:1080})); loaderArray.push(new VideoLoader(url2, {name:"slide2", width:1920, height:1080, autoPlay:false})); loaderArray.push(new VideoLoader(url3, {name:"slide3", width:1920, height:1080, autoPlay:false})); loaderArray.push(new VideoLoader(url4, {name:"slide4", width:1920, height:1080, autoPlay:false})); loaderArray.push(new VideoLoader(url5, {name:"slide5", width:1920, height:1080, autoPlay:false})); loaderArray.push(new VideoLoader(url6, {name:"slide6", width:1920, height:1080, autoPlay:false})); presentationLoader.append(loaderArray[0]); presentationLoader.append(loaderArray[1]); presentationLoader.load(); function goForward():void { if(currentSlideIndex<loaderArray.length - 1) { currentSlideIndex++; //This is where problems happen the second time revisiting the content. thisSlide = loaderArray[currentSlideIndex].content; nextSlide.addChild(thisSlide); //Imagine transition code here rearangeSlides(1); } } function goBackward():void { if(currentSlideIndex>0) { currentSlideIndex--; thisSlide = loaderArray[currentSlideIndex].content; previousSlide.addChild(thisSlide); //Imagine transition code here rearangeSlides(-1); } } function rearangeSlides(param1:Number):void { var tempContent:ContentDisplay; if (param1 > 0) { //Going forward tempContent = ContentDisplay(nextSlide.getChildAt(0)); //Remove content two back, we want the immediately previous loader to keep content ready if (loaderArray[currentSlideIndex - 2] is VideoLoader) VideoLoader(loaderArray[currentSlideIndex - 2]).dispose(true); trace(loaderArray); if (currentSlide.numChildren > 0) currentSlide.removeChildAt(0); currentSlide.addChild(tempContent); currentSlide.x = 0; nextSlide.x = 1920; } else if (param1 < 0) { //Going backwards tempContent = ContentDisplay(previousSlide.getChildAt(0)); //Remove content two forward, we want the immediately next loader to keep content ready if (loaderArray[currentSlideIndex + 2] is VideoLoader) VideoLoader(loaderArray[currentSlideIndex + 2]).dispose(true); currentSlide.removeChildAt(0); currentSlide.addChild(previousSlide.getChildAt(0)); currentSlide.x = 0; previousSlide.x = -1920; } }
×
×
  • Create New...