1

正如标题中所说。这是我目前正在使用的脚本

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","part102.mp3","part103.mp3","part104.mp3","part105.mp3","part106.mp3","part107.mp3","part108.mp3","part109.mp3","part110.mp3","part111.mp3","part112.mp3","part113.mp3","part114.mp3","part115.mp3","part116.mp3","part117.mp3","part118.mp3","part119.mp3","part120.mp3","part121.mp3","part122.mp3","part123.mp3","part124.mp3","part125.mp3","part126.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("parts/"+songs)); 
    soundChannel=sound.play();
    soundChannel.addEventListener(Event.SOUND_COMPLETE,playrandomsong);
}

function playrandomsong(e:Event)
{
    playsong();
}

它可以工作......但只有在与 SWF 文件类似的目录中时,我才将其另存为。我需要像 MP3 在“D:/parts”中一样工作。Actionscript 和 flash 不是我真正的东西,所以我为我的笨拙表示歉意,但我最终需要一个 SWF 文件,它可以对位于特定目录中的 MP3 进行随机播放……因此,非常感谢任何帮助!谢谢你。

4

2 回答 2

1

从您的问题看来,您只想在本地播放 swf?

如果是这样,您应该能够通过更改从另一个位置加载本地文件:

sound.load(new URLRequest("parts/"+songs)); 

sound.load(new URLRequest("file:///D:/path/to/parts/"+songs)); 
于 2012-10-11T07:36:26.280 回答
0

据我了解,没有必要完全制作网络应用程序。它将在本地工作。因此,您可以通过 ActionScript 3 制作 AIR 应用程序。

于 2012-10-10T21:03:21.810 回答