How does Flash Player load the main SWF file?

UPDATE:

It seems that everyone has not carefully read my question, all the answers suggest me to preload or use external assets. Therefore, anyone who wishes to answer, please pay attention to the bold questions in this post. Thank!


I am developing a simple Flash application that has only one SWF file. I want the SWF movie to start playing as soon as possible, so I do not create a preloader for it. What happens if my actionscript refers to resources that are not yet loaded?

For example, the code causes the game point to go from frame 1to frame 20when the movie has just been downloaded before the frame 10. In this case, will there be a flash player?

  • Block script execution, stop playback, continue loading from the frame 11to 20(without executing the script), go to the frame 20and call the script in this frame when loading?
  • Block script execution, stop playback, ignore the loaded frame 11on 19, load the frame 20, go to the frame 20and call the script in this frame?
  • Ignore the transition to the frame 20, continue execution of the following statements after the transition to the frame 20.
  • Or something else?

Flash Player 20, event , 20 ?

. , (, ...) , .

!

+5
5

, Adobe Flash Professional, . , Adobe Flash:

  • , , , ActionScript.
  • Control → Test Movie → in Flash Professional:
  • "" → " ", .
  • , "" .

script , Flash- :

  • 1 .
  • 1
  • script 1
  • 1
  • 2 .. ( 1, 2 , 2, script, ...)

script , . 1 20, Flash- :

  • script 1 ( ) 1.
  • 20 , 20, script . , ( 10), script .
0

Flash . . , 20, .

Flash - , , , , . , , , Loader.

+3

Flash- 20. . , , 20, 10, 10.

, null. , . .

-frame- - 2 . , . , , , , .

, .

package 
{
    import flash.display.DisplayObject;
    import flash.display.MovieClip;
    import flash.display.StageAlign;
    import flash.display.StageScaleMode;
    import flash.events.Event;
    import flash.events.IOErrorEvent;
    import flash.events.ProgressEvent;
    import flash.utils.getDefinitionByName;

    /**
     * ...
     * @author Zachary Foley
     */
    public class Preloader extends MovieClip 
    {

        public function Preloader() 
        {
            if (stage) {
                stage.scaleMode = StageScaleMode.NO_SCALE;
                stage.align = StageAlign.TOP_LEFT;
            }
            addEventListener(Event.ENTER_FRAME, checkFrame);
            loaderInfo.addEventListener(ProgressEvent.PROGRESS, progress);
            loaderInfo.addEventListener(IOErrorEvent.IO_ERROR, ioError);

            // TODO show loader
        }

        private function ioError(e:IOErrorEvent):void 
        {
            trace(e.text);
        }

        private function progress(e:ProgressEvent):void 
        {
            // TODO update loader
        }

        private function checkFrame(e:Event):void 
        {
            if (currentFrame == totalFrames) 
            {
                stop();
                loadingFinished();
            }
        }

        private function loadingFinished():void 
        {
            removeEventListener(Event.ENTER_FRAME, checkFrame);
            loaderInfo.removeEventListener(ProgressEvent.PROGRESS, progress);
            loaderInfo.removeEventListener(IOErrorEvent.IO_ERROR, ioError);

            // TODO hide loader

            startup();
        }

        private function startup():void 
        {
            var mainClass:Class = getDefinitionByName("Main") as Class;
            addChild(new mainClass() as DisplayObject);
        }

    }

}

, frame . frame :

-frame start Main
+1

.

, , . . , . , , .

. ..

In other words, you have to wait for the first impression before the next download of the screen assets. And this time do not show the preloader.

0
source

in AS2, try this code. Loading of progress indications on the first frame, and the main content is displayed on the 3rd frame. This code is in the ActionScript 2.0 link (getBytesLoaded). http://help.adobe.com/ko_KR/AS2LCR/Flash_10.0/00001304.html#1333866

if (this._framesloaded<this._totalframes) {
    this.gotoAndPlay(1);
} else {
    this.gotoAndStop(3);
}

in AS3, use this.

this.loaderInfo.addEventListener(Event.COMPLETE, completeHandler);
0
source

All Articles