开发者

actionscript flash - load frames while playing

Good day to all. I have a question about flash... is it possible to load first 2-3 frames开发者_开发知识库 of a a clip and while those are playing to load the rest?

Also if the answer is affirmative at the first question id it possible to change the loading order considering what happened in the first part?

And if yes... how?

Thank you for help.


In short, when loading, the flash player will start on frame 1, and will continue to sit there until all the data on frame 1 has been loaded. Only then will it proceed to the next frame. You can get a detailed report of how many bytes of data is exported to each frame by checking the "Generate Build Report" checkbox in the "Flash" tab under "File->Publisher Settings"

To get a simple loading display going, add a TextField named "loader_txt" in frame 1, and add this code in action:

  stop();

  this.addEventListener(Event.ENTER_FRAME, loading);

  function loading(e:Event):void{

      var total:Number = this.stage.loaderInfo.bytesTotal;
      var loaded:Number = this.stage.loaderInfo.bytesLoaded;

      loader_txt.text = Math.floor((loaded/total)*100)+ "%";

    if (total == loaded){
      play();
      this.removeEventListener(Event.ENTER_FRAME, loading);
    }

  }

To make sure your assets and actionscript code are exported beyond frame 1 so above code can kick in immediately when flash movie begins to load, go to "File->Publish Settings", select "Flash" tab, and click on "Settings..." button to the right of "Script". A dialog should show up. In that dialog, under "Export classes in frame:", enter 2.

For assets in library, you may need to do similar thing. Right click on a library asset and select properties, and you'll see the option to uncheck "Export in frame 1". If you uncheck it (which means flash movie can start to play before this asset is loaded), you will have to make sure you have a reference to that symbol somewhere beyond frame 1 in the timeline, otherwise Flash will omit it from the compilation.

Good luck!


Answer #1: Yes.

Flash movies stream by default, meaning they start to play as soon as frame 1 is loaded.
You have to make sure, though, that none of your symbols from the library are embedded into frame 1 - otherwise loading the first frame will take longer. Also, using runtime shared libraries will have a similar effect.

Answer #2: If you mean to change the load order of the same SWF you are looping while loading, the answer is no. You can of course change the load order of other SWFs you are loading into the first movie.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜