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?
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...
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...