6 Replies Latest reply on Jul 27, 2007 2:51 PM by masterkrang

    Loader component plays wrong scene after loading

    masterkrang Level 1
      hello, i've created a montage in flash that displays photos consecutively on the timeline. i have the montage.swf called into the main.swf using the AS 3.0 Loader class (see code attached). the problem is, when i call the Event.COMPLETE function that add's the child montage to the stage, the montage starts on the 3rd photo on the third or fourth pic in the timeline. Anybody know why it would be starting late based on my code? you can see the file online at http://kurtcom.com/dante_photography/dante_main.html ... the first photo is supposed to be the two shots of girl, one where she is wearing a motorcycle shirt, not the girl in her underwear :)

      Thanks!
        • 1. Re: Loader component plays wrong scene after loading
          kglad Adobe Community Professional & MVP
          no code was attached. use the reply ( not quick reply) to see the attach code option.
          • 2. Re: Loader component plays wrong scene after loading
            masterkrang Level 1
            stop();

            import flash.display.Loader;
            import flash.display.LoaderInfo;
            import flash.net.URLRequest;
            import flash.text.TextField;
            import flash.events.Event;
            import flash.events.ProgressEvent;

            var myLoader:Loader = new Loader();
            var myRequest:URLRequest = new URLRequest("dante_montage.swf");
            var loadProgress_txt:TextField = new TextField();

            myLoader.load(myRequest);

            myLoader.contentLoaderInfo.addEventListener(Event.OPEN,showPreloader);
            myLoader.contentLoaderInfo.addEventListener(ProgressEvent.PROGRESS,showProgress);
            myLoader.contentLoaderInfo.addEventListener(Event.COMPLETE,showLoadResult);

            myLoader.x = 50;
            myLoader.y = 50;
            loadProgress_txt.x = 505;
            loadProgress_txt.y = 350;



            function showPreloader(evt:Event):void {
            addChild(loadProgress_txt);
            }

            function showProgress(evt:ProgressEvent):void {
            var percentTotal:Number = Number(evt.bytesLoaded) / Number(evt.bytesTotal) * 100;
            loadProgress_txt.text = String(Math.round(percentTotal)) + "%";
            //"loaded: " + evt.bytesLoaded + " from " + evt.bytesTotal + "\n";

            }

            function showLoadResult(evt:Event):void {
            removeChild(loadProgress_txt);
            addChild(myLoader);
            }
            • 3. Re: Loader component plays wrong scene after loading
              kglad Adobe Community Professional & MVP
              that code loads dante_montage.swf, displays its load progress and removes the preloader when loading is complete, if all the instance names are correct.

              that code loads nothing sequentially.
              • 4. Re: Loader component plays wrong scene after loading
                masterkrang Level 1
                you're right, the code does not load anything sequentially, but the swf that's being called in has a timeline that displays photos sequentially on the timeline.

                so to simplify.... there is the main swf that calls in the montage (the code i have pasted in is from the main swf). the montage has about 500 frames on it which displays around 8 photographs on a timeline. the problem is that when the montage is loaded and appears within the main swf, the montage has already started before it is added to the stage. it's either that, or it is simply starting on the wrong frame.

                if i understand correctly, when you load an external swf, then add it to the stage on Event.Complete, it should play frame 1 first, not frame 5, 100, or 200...

                any other ideas?

                • 5. Re: Loader component plays wrong scene after loading
                  kglad Adobe Community Professional & MVP
                  put a stop() on frame 1 of your external swf and direct its timeline to play after loading is complete AND your swf is initialize (Event.INIT).
                  • 6. Re: Loader component plays wrong scene after loading
                    masterkrang Level 1
                    how do i test the Event.INIT?

                    i tried this:

                    stop();

                    import flash.events.Event;
                    import flash.events.ProgressEvent;

                    this.addEventListener(Event.INIT, blahblah);

                    function blahblah(evt:Event):void {
                    _root.gotoAndPlay(2);
                    }

                    but it didn't work. what am i doing wrong?

                    thanks :)