Preloader Skips Frames
A Flash Developer Resource Site

Results 1 to 5 of 5

Thread: Preloader Skips Frames

  1. #1
    Junior Member
    Join Date
    Aug 2007
    Posts
    5

    Preloader Skips Frames

    I've made a preloader using a document class and the following code:
    Code:
    package 
    {
    	import flash.display.MovieClip;
    	import flash.display.Loader;
    	import flash.events.*;
    	import flash.net.URLRequest;
    
    	public class Loading extends MovieClip 
    	{
    		private var url:String;
    		private var loader:Loader;
    
    		public function Loading() 
    		{
    			url='test.swf';
    			var request:URLRequest=new URLRequest(url);
    			loader=new Loader();
    			initListeners(loader.contentLoaderInfo);
    			loader.load(request);
    		}
    		
    		private function initListeners(dispatcher:IEventDispatcher):void 
    		{
    			dispatcher.addEventListener(Event.COMPLETE,onComplete);
    		}
    		
    		private function onComplete(event:Event):void 
    		{
    			removeChild(preloader_mc);
    			addChild(loader);
    		}
    	}
    }
    The preloader_mc is a 40 frame movieclip (instanced in the first frame of the timeline). The problem is when it starts playing the test movie it starts playing at however many frames it's played. So if the preloader movie clip plays through one, it skips 40 frames, twice and it skips 80, etc.

    I've tried putting a gotoAndPlay(1) after the addChild call, but that doesn't help. Any ideas?

  2. #2
    Senior Member joshstrike's Avatar
    Join Date
    Jan 2001
    Location
    Alhama de Granada, España
    Posts
    1,131
    Is your timeline 40 frames long?
    Is it two frames long and just looping or something?

    Not saying this to be a code nazi, but you seem like a fairly sophisticated coder, I don't understand why you'd do an AS3 project and actually place anything on a timeline. If you had one frame in your FLA and just loaded the preloader_mc from the document class, you wouldn't be having this problem, and you likely won't have any of a hundred other problems you're about to have when you get past this phase of the project...

  3. #3
    Junior Member
    Join Date
    Aug 2007
    Posts
    5
    Well I'm not a fantastic AS coder, and literally just started with AS3 on this project.

    At the moment there's 1 frame on the main timeline, with the preloader_mc which is 40 frames long. I'll have to wait till work tomorrow to try out your idea, hopefully it'll work.

    Since I was doing a separate preloader SWF I've actually completed the rest of the project (not a single line of AS needed ) it's just this frame skipping problem left...

  4. #4
    Junior Member
    Join Date
    Aug 2007
    Posts
    5
    (deleted)
    Last edited by notacake; 08-28-2007 at 06:06 AM. Reason: Accidental repost

  5. #5
    Junior Member
    Join Date
    Aug 2007
    Posts
    5
    Ok I've removed the preloader_mc instance from the timeline (and remove the single frame) so the timeline is now blank, and changed the code to this:

    Code:
    package 
    {
    	import flash.display.MovieClip;
    	import flash.display.Loader;
    	import flash.events.*;
    	import flash.net.URLRequest;
    
    	public class Loading extends MovieClip 
    	{
    		private var url:String;
    		private var loader:Loader;
    		private var preloader_mc:preloader;
    
    		public function Loading() 
    		{
    			preloader_mc = new preloader();
    			preloader_mc.x = 90;
    			preloader_mc.y = 46;
    			addChild(preloader_mc);
    			url='mercury.swf';
    			var request:URLRequest=new URLRequest(url);
    			loader=new Loader();
    			initListeners(loader.contentLoaderInfo);
    			loader.load(request);
    		}
    		
    		private function initListeners(dispatcher:IEventDispatcher):void 
    		{
    			dispatcher.addEventListener(Event.COMPLETE,onComplete);
    		}
    		
    		private function onComplete(event:Event):void 
    		{
    			removeChild(preloader_mc);
    			gotoAndStop(1, "Scene 1");
    			addChild(loader);
    			play();
    		}
    	}
    }
    Yet it still has the same problem.
    Attached Files Attached Files

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  




Click Here to Expand Forum to Full Width


HTML5 Development Center

Poll by Flashkit.com