0
import flash.media.Sound;
import flash.net.URLRequest;
import flash.media.SoundChannel;
import flash.events.Event;

 playsong();
//var songs:Array=new Array("part0.mp3","part1.mp3","part2.mp3","part3.mp3","part4.mp3","part5.mp3","part6.mp3","part7.mp3","part8.mp3","part9.mp3","part10.mp3","part11.mp3","part12.mp3","part13.mp3","part14.mp3","part15.mp3","part16.mp3","part17.mp3","part18.mp3","part19.mp3","part20.mp3","part21.mp3","part22.mp3","part23.mp3","part24.mp3","part25.mp3","part26.mp3","part27.mp3","part28.mp3","part29.mp3","part30.mp3","part31.mp3","part32.mp3","part33.mp3","part34.mp3","part35.mp3","part36.mp3","part37.mp3","part38.mp3","part39.mp3","part40.mp3","part41.mp3","part42.mp3","part43.mp3","part44.mp3","part45.mp3","part46.mp3","part47.mp3","part48.mp3","part49.mp3","part50.mp3","part51.mp3","part52.mp3","part53.mp3","part54.mp3","part55.mp3","part56.mp3","part57.mp3","part58.mp3","part59.mp3","part60.mp3","part61.mp3","part62.mp3","part63.mp3","part64.mp3","part65.mp3","part66.mp3","part67.mp3","part68.mp3","part69.mp3","part70.mp3","part71.mp3","part72.mp3","part73.mp3","part74.mp3","part75.mp3","part76.mp3","part77.mp3","part78.mp3","part79.mp3","part80.mp3","part81.mp3","part82.mp3","part83.mp3","part84.mp3","part85.mp3","part86.mp3","part87.mp3","part88.mp3","part89.mp3","part90.mp3","part91.mp3","part92.mp3","part93.mp3","part94.mp3","part95.mp3","part96.mp3","part97.mp3","part98.mp3","part99.mp3","part100.mp3","part101.mp3");
 var sound:Sound;
 var soundChannel:SoundChannel;
 var randnum:uint;
 function playsong()
 {
 randnum=Math.floor(Math.random()*127);
 sound=new Sound();
 var songs:String= "part" + randnum + ".mp3";  
 sound.load(new URLRequest("file:///D:/parts/"+songs));
 soundChannel=sound.play();
 soundChannel.addEventListener(Event.SOUND_COMPLETE,playrandomsong);
 }
 function playrandomsong(e:Event)
 {
 playsong();
 }

これは、ローカルディレクトリから配列内のMP3をランダム化するために使用しているActionscript3コードです。それは動作しますが、私の問題は、私がそれを使用しているアプリケーションが古く、AS3をサポートしていないことです-AS2以前のみ。このコードに相当するものが何であるかを誰かが知っていますか?

4

1 に答える 1

1

AS2には、インポートされたパッケージは存在せず、、、、またはクラスはなくEventSoundChannelクラスURLRequestインターフェイスSoundは異なります。

未テスト:

var sound:Sound;
var randnum:Number;

function playsong()
{
    randnum = Math.floor(Math.random() * 127);
    var songs:String = "part" + randnum + ".mp3";  

    sound = new Sound();
    sound.onSoundComplete = playrandomsong;
    sound.loadSound("file:///D:/parts/" + songs, true);
}

function playrandomsong()
{
    playsong();
}
于 2012-10-11T14:34:27.770 に答える