|
下記のfunctionを読込んで
playMP3(path:String); //path:String -> 外部mp3ファイルのパス とすればロード完了と同時に自動的に再生される。 (ver7以上) var bgmMP3:Sound; function playMP3(path:String):Void { bgmMP3 = new Sound(); bgmMP3.onLoad = function() { bgmMP3.start(0, 999); delete this.onLoad; }; bgmMP3.loadSound(path, false); if (bgmMP3.getBytesLoaded()>bgmMP3.getBytesTotal-10) { bgmMP3.onLoad(); } }
非常に使う関数です。私の場合は、ゲームのハイスコア送信時に入力する文字列に適応しています。
function dlsp(str:String):String { var str2:String = str; while (str2.charAt(0) == " " || str2.charAt(0) == " ") { str2 = str2.slice(1, str2.length); } while (str2.charAt(str2.length-1) == " " || str2.charAt(str2.length-1) == " ") { str2 = str2.slice(0, str2.length-1); } return str2; } 引数 str:String スペース削除対象文字列 戻り値 str2:String スペース削除後文字列 [続きを読む...]
リンケイジを使って読み込むサウンドやMC類は「最初のフレームに書き出し」というチェックをはずしておきます。
このままだとロードされないので、それらのシンボルを詰め込んだMCを最初の適当なフレームXにおいておきます。 あとはX以前にNowLoadingを作り、X以降のフレームでattachSoundやattachMovieを使えばOKです。 特にLinkageをつけたサウンドやMCが多い時には有効です。 |