Jump to content
Search Community

caffrey75

Members
  • Posts

    26
  • Joined

  • Last visited

Everything posted by caffrey75

  1. Hi there, First off, thank you so much greensock guy (Jack) for your amazing creations. I only started using TweenLite/TweenMax the other day because I got so fed up of Flash's own limited Tween engine, then I moved on to coding a preloader and just couldn't believe my luck when I then discovered LoaderMax. You've saved me literally hours/days of time, enabling me to concentrate on stuff that I AM good at. I hope your stuff makes you a millionaire, because you definitely deserve it Typically I've run into a problem with LoaderMax because of my own ineptitute. After 6 years of coding in AS2, I finally moved onto AS3 2 weeks ago and am just about getting to grips with it, but my coding has probably always been generally awful, although I try What I'm trying to do is preload part of a swf from the timeline of the main swf before playing. These swfs generally contain video and some other content (the video being on the main timeline of each, so that I can partially preload properly (I got some help from this thread viewtopic.php?f=6&t=5189 as a guy there was doing similar). Problem I'm getting is that I've got two or three swfs that I want to load in this fashion (partial preload and then play), but they would load in and overwrite the swf already in place. Everything worked brilliantly until I discovered that, if I attempted to load another swf BEFORE the first one had loaded in full, not only was the first one still in-place (despite calling removeChild), but if I attempted to reset the _loader object I'd also get - I'm clearly doing something wrong, although I've tried various things and really attempted to find the solution on the boards/in the documentation before posting. The reason I haven't used the queueing options available to preload these swfs is probably a combination of being a tad nervous of it, and basically wanting to learn to walk before flying. Here's my commented code. Sorry for my waffle, but I try to explain problem as fully as possible, and apologies for my messy code hehe var loadedSWF:MovieClip; //declare the loadedSWF 'holder' outside of the function function loadPage() { //function to load a new page on a button click. showLoader(); //shows a loading anim var minPercentLoaded:Number=pagesArray[pageToLoad].minPercentToLoad/100; //the amount I want to load before playing (taken from an array of page URLs and other info) if (loadedSWF!=null) { //my attempts to reset after checking that there IS another swf currently playing/being loaded or both _loader.dispose(true); //not sure about this, been trying various things (pause, cancel etc) to try and avert problem. maincontentMC.contentholderMC.loaderMC.removeChild(loadedSWF); //attempt to remove the previous swf from its location. Successful but only if the swf has been loaded in full. loadedSWF=null; //sets the loaded swf back to null } var _loader:SWFLoader = new SWFLoader( pagesArray[pageToLoad].file, {auditSize:false, autoPlay:false, onProgress:_onLoaderProgress } ); //loads a file based on its position in the pagesArray. _loader.load(); function _onLoaderProgress(event : Event):void { //not too sure if I should have this nested in the load() function, but it seems to work fine when not simulating download. preloader.textMC.percentText.text= (Math.ceil(((event.target.progress)*100)*pagesArray[pageToLoad].minPercentToLoad).toString())+"%"; //sets the progress display in the preloader animation textfield. if (loadedSWF == null && _loader.progress >= minPercentLoaded) { //checks that loadedSWF is null and minimum amount has loaded before playing loadedSWF =_loader.rawContent as MovieClip; if (loadedSWF) { maincontentMC.contentholderMC.loaderMC.addChild(loadedSWF); //adds the loadedSWF into the correct place hideLoader();//hides the loading animation loadedSWF.x=(~(pagesArray[pageToLoad].dim[0]/2)+1); loadedSWF.y=(~(pagesArray[pageToLoad].dim[1]/2)+1); //sets the correct x and y values openMask(); //reveals the loaded swf (the openMask function also orders it to play when done. } } } }
×
×
  • Create New...