2 简单音乐播放器的错误问题

2 error problems for simple music players

提问人:Isaac Yeap Jie Ling 提问时间:11/13/2023 更新时间:11/13/2023 访问量:29

问:

我有 2 个错误: #2044:未处理的 IOErrorEvent:。text=Error #2032:流错误。

我测试了几次,我同时对音乐播放器场景进行了未处理的 IOErrorEvent 和 Stream Error。我找到了这个视频如何使用 actionscript 3.0 创建一个简单的 MP3 播放器, 任何人都可以修复这些错误吗?

    var myMusic:Sound = new Sound();
    var musicChannel: SoundChannel = new SoundChannel();
    var musicIndex: Number = 0;
    var music: Array = new Array();
    var pp: Boolean = true;
    
    music = ['Aqua Man- Guitar Remix', 'Summer Treasure Hunt Event 1', 'Summer Treasure Hunt Event 2',
        'Sizzling Heat! Splendid Summer Event', 'Brick Dive', 'Bloocheep Ocean','Dire Dire Docks Remix - Calm Waters', 
        'Dire Dire Docks Remix - Calm Waters', 'Mario Teaches Typing 2 (1996) - Underwater', 'Treasure Cove! Level 1', 
        'Treasure Cove! Level 2', 'Treasure Cove! Level 3', 'Under Pressure'];
    
    myMusic.load(new URLRequest("E:/Flash Animations/Folder 1/Games/Bit-Bot Math Voyage/Music"+[musicIndex]));
ActionScript-3 文本 IOerrorError

评论

0赞 Organis 11/13/2023
最可能的原因 — 生成的 URL 错误,特别是 .../Music“+[musicIndex] 可能导致 .../Music0”。您应该跟踪 URL,然后将其粘贴到资源管理器中,看看它是否确实是 MP3 文件的有效 URL。
0赞 Isaac Yeap Jie Ling 11/13/2023
TypeError:错误 #1034:Type 强制失败:无法将“E:/Flash Animations/Folder 1/Games/Bit-Bot Math Voyage/MusicAqua Man- Guitar Remix”转换为 flash.net.URLRequest。我追踪它是 [object Sound],然后我更改为 .../“Music+[musicIndex]

答:

0赞 Michael 11/13/2023 #1

看起来您的数组访问方法有错误:

myMusic.load(
    new URLRequest(
        "E:/Flash Animations/Folder 1/Games/Bit-Bot Math Voyage/Music" +
        [musicIndex] // This creates a new array with one integer element
));

我想你想要:

myMusic.load(
    new URLRequest(
        "E:/Flash Animations/Folder 1/Games/Bit-Bot Math Voyage/Music" +
        music[musicIndex] // This returns the musicIndex element from the music array
));

你可能也想要一个?/Music

myMusic.load(
    new URLRequest(
        "E:/Flash Animations/Folder 1/Games/Bit-Bot Math Voyage/Music/" +
        music[musicIndex] // This returns the musicIndex element from the music array
));

评论

0赞 Isaac Yeap Jie Ling 11/13/2023
我已经设法解决了这个问题。但是我需要音乐名称而不看到“.mp3”