プリローダー


/ Published in: ActionScript
Save to your folder(s)

・2フレーム目に「cont」
・ダイナミックテキスト名「parcentage_txt」
・ローダー名(ムービークリップ)「bar_mc」
Source:
onClipEvent (load) {
//最初は非表示に
this._xscale = 0;
}


Copy this code and paste it in your HTML
  1. //まず最初に再生を停止
  2. this.stop();
  3. //■■=====変数の初期化
  4. //パーセンテージ
  5. nParcentage = 0;
  6. //全体のバイト数を取得
  7. nTotal = this.getBytesTotal();
  8. //■■=====function定義
  9. function xPreload() {
  10. //読み込み済みバイト数を取得
  11. nLoaded = this.getBytesLoaded();
  12. //読み込み状態を監視して、読み込み終了なら指定フレームへ移動
  13. //読み込み終了前ならパーセンテージとバーを操作
  14. if (nTotal<=nLoaded) {
  15. this.gotoAndStop("cont");
  16. //プリロード処理を消去
  17. delete this.onEnterFrame;
  18. } else {
  19. //パーセンテージを計算
  20. nParcentage = Math.round(100*nLoaded/nTotal);
  21. //バーの長さを変更
  22. bar_mc._xscale = nParcentage;
  23. //パーセンテージのテキストを変更
  24. parcentage_txt.text = nParcentage+" %";
  25. }
  26. }
  27. //■■=====読み込み判定処理を組み込み
  28. this.onEnterFrame = xPreload;

Report this snippet


Comments

RSS Icon Subscribe to comments

You need to login to post a comment.