1

xml ファイルを介して読み込まれた一連の曲を含むフラッシュ プレーヤーがあります。

ファイルを選択するまで、ファイルのストリームが開始されません。

8 つのファイルのそれぞれをすばやく循環すると、フラッシュは 8 つのファイルのそれぞれを同時にダウンロードしようとし始めます。

ダウンロード中のファイルをクリアする方法があるかどうか疑問に思っています。そのため、誰かがたくさんのトラック名をクリックしても、帯域幅が食い尽くされることはありません。

mySound.clear や mySound.stopStreaming.. のようなものが最適です。

誰かが以前にこの問題を抱えていましたか?

よろしく、

クリス

4

2 に答える 2

1

Sound.Close()を確認してください。

ドキュメントから:「ストリームを閉じ、データのダウンロードを停止します。close() メソッドが呼び出された後、ストリームからデータを読み取ることはできません。

これは、リンクされたドキュメントのソース コードの例です。

package {
    import flash.display.Sprite;
    import flash.net.URLRequest;
    import flash.media.Sound;    
    import flash.text.TextField;
    import flash.text.TextFieldAutoSize;
    import flash.events.MouseEvent;
    import flash.errors.IOError;
    import flash.events.IOErrorEvent;

    public class Sound_closeExample extends Sprite {
        private var snd:Sound = new Sound();
        private var button:TextField = new TextField();
        private var req:URLRequest = new URLRequest("http://av.adobe.com/podcast/csbu_dev_podcast_epi_2.mp3");

        public function Sound_closeExample() {
            button.x = 10;
            button.y = 10;
            button.text = "START";
            button.border = true;
            button.background = true;
            button.selectable = false;
            button.autoSize = TextFieldAutoSize.LEFT;

            button.addEventListener(MouseEvent.CLICK, clickHandler);

            this.addChild(button);
        }

        private function clickHandler(e:MouseEvent):void {

            if(button.text == "START") {

                snd.load(req);
                snd.play();        

                snd.addEventListener(IOErrorEvent.IO_ERROR, errorHandler);

                button.text = "STOP";
            }
            else if(button.text == "STOP") {

                try {
                    snd.close();
                    button.text = "Wait for loaded stream to finish.";
                }
                catch (error:IOError) {
                    button.text = "Couldn't close stream " + error.message;    
                }
            }
        }

        private function errorHandler(event:IOErrorEvent):void {
                button.text = "Couldn't load the file " + event.text;
        }
    }
}
于 2008-11-03T20:44:26.123 に答える
0

あなたが次のようなことをした場合:

MySoundObject = undefined;

それはそれをする必要があります。

于 2008-09-16T18:16:20.790 に答える