Flex 4 “Error #2032: Stream Error. URL: “

本文探讨了在Flex4 Cookbook中遇到的SWFLoader事件处理问题。作者尝试使用Flex编译SWF文件作为加载目标时遇到了运行错误。通过调整编译设置,将资源文件一并编译进SWF,成功解决了“Error#2032: StreamError.URL”错误。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

今天研究Flex 4 Cookbook 里面的swfloader的事件处理,就想找一个swf,还没现成的swf就像用Flex正好编译一个swf文件然后当做加载

但是发现编译出来的swf文件居然不能运行,这就奇怪了,在Flex3中是绝对可以运行的,挺好奇
而且报的是
“Error #2032: Stream Error. URL: “ 这个错误
那么我在工程的bin-debug文件夹下运行这个swf还是可以运行的
而变异的bin-debug文件夹里头是有默认的Flex运行库文件,我想应该就是这有问题

那我就想到了应该是编译有问题

在FlashBuilder 里面找了找
发现有这一项

[img]http://dl.iteye.com/upload/attachment/302982/32ec36df-1e7b-3558-a9d3-7a029763b3bc.jpg[/img]

Framework linkage 里面默认是使用SDK默认的方式,而不是把资源文件一通编译进去
所以调整为编译进去就可以了

唯独不是太理解的就是为什么要这样呢,如果说减少swf体积,但是访问的时候一样会访问加载资源文件的啊
不过问题总算是解决了
<!DOCTYPE html> <html lang="zh-CN"> <head> <meta charset="UTF-8"> <meta name="viewport" content="width=device-width, initial-scale=1.0"> <title>百度AI植物识别</title> <style> body { display: flex; flex-direction: column; align-items: center; } video { width: 100%; max-width: 640px; border-radius: 8px; box-shadow: 0 2px 8px rgba(0,0,0,0.1); } .loading-spinner { display: none; width: 40px; height: 40px; border: 4px solid rgba(0, 0, 0, 0.1); border-left-color: #7986cb; border-radius: 50%; animation: spin 1s linear infinite; margin: 20px 0; } @keyframes spin { to { transform: rotate(360deg); } } #result { margin: 20px; padding: 15px; max-width: 640px; width: 100%; border: 1px solid #eee; border-radius: 8px; } #capture { margin: 20px 0; padding: 12px 32px; font-size: 16px; background: #4CAF50; color: white; border: none; border-radius: 25px; cursor: pointer; transition: all 0.3s; } #capture:disabled { background: #cccccc; cursor: not-allowed; } .result-item { margin: 10px 0; padding: 10px; background: #f8f8f8; border-radius: 4px; } </style> </head> <body> <video id="preview" autoplay playsinline></video> <div class="loading-spinner"></div> <button id="capture">拍摄识别</button> <div id="result"></div> <script> // 百度AI配置 const config = { apiKey: &#39;z3X2W5zIn2qXSp95bhlj6cA6&#39;, secretKey: &#39;zdZvfijzBpgdgm172jFGtxGQe4yrVaUH&#39;, plantApi: &#39;https://aip.baidubce.com/rest/2.0/image-classify/v1/plant&#39; }; // DOM元素 const video = document.getElementById(&#39;preview&#39;); const captureBtn = document.getElementById(&#39;capture&#39;); const loadingSpinner = document.querySelector(&#39;.loading-spinner&#39;); const resultDiv = document.getElementById(&#39;result&#39;); let accessToken = &#39;&#39;; // 初始化摄像头 async function initCamera() { try { const stream = await navigator.mediaDevices.getUserMedia({ video: { facingMode: "environm
最新发布
03-29
<!DOCTYPE html> <html lang="zh-CN"> <head> <meta charset="UTF-8" /> <meta name="viewport" content="width=device-width, initial-scale=1.0"/> <title>扫码解锁视频</title> <style> * { margin: 0; padding: 0; box-sizing: border-box; } body { font-family: Arial, sans-serif; background: #000; color: #fff; height: 100vh; overflow: hidden; } .slider { display: flex; width: 400%; height: 100%; transition: transform 0.3s ease; } .slide { width: 100vw; height: 100vh; flex-shrink: 0; position: relative; overflow: hidden; background: #111; } video { width: 100%; height: 100%; object-fit: cover; } /* 未解锁提示文字 */ .lock-tip { position: absolute; top: 20px; left: 50%; transform: translateX(-50%); color: #fff; background: rgba(0, 0, 0, 0.5); padding: 6px 12px; border-radius: 5px; font-size: 16px; display: none; z-index: 2; } .hint { position: absolute; bottom: 40px; width: 100%; text-align: center; color: rgba(255,255,255,0.8); font-size: 14px; z-index: 2; } /* 扫码解锁按钮 */ #scanButton { position: fixed; top: 20px; right: 20px; z-index: 9999; background: #fff; color: #000; border: none; padding: 10px 15px; border-radius: 5px; font-size: 14px; cursor: pointer; } /* 分页指示器 */ .pagination { position: absolute; bottom: 10px; width: 100%; display: flex; justify-content: center; gap: 8px; } .dot { width: 10px; height: 10px; border-radius: 50%; background: rgba(255,255,255,0.3); transition: background 0.3s; } .dot.active { background: #fff; } </style> </head> <body> <!-- 扫码解锁按钮 --> <bu
03-14
参考下面这段代码,将你这段js代码整合进去 <!DOCTYPE html> <html lang="zh"> <head> <meta charset="UTF-8"> <meta name="viewport" content="width=device-width, initial-scale=1.0"> <title>流式音频播放演示</title> </head> <body> <div style="display: flex; justify-content: space-between"> <div style="width: 50%"> <h3>输入文本:</h3> <textarea id="prompt" style="width: 90%; height: 200px"></textarea> <br/><br/> <button id="playButton">开始生成</button> </div> <div style="width: 50%"> <h3>音频输出:</h3> <audio id="audioPlayer" controls> 您的浏览器不支持音频元素。 </audio> </div> </div> <script> document.getElementById(&#39;playButton&#39;).addEventListener(&#39;click&#39;, async () => { await startStreamingAudio(); }); async function startStreamingAudio() { const mediaSource = new MediaSource(); const audioPlayer = document.getElementById(&#39;audioPlayer&#39;); let first = true; // 重置播放器 audioPlayer.pause(); audioPlayer.src = URL.createObjectURL(mediaSource); return new Promise((resolve) => { mediaSource.addEventListener(&#39;sourceopen&#39;, async () => { try { const sourceBuffer = mediaSource.addSourceBuffer(&#39;audio/mpeg&#39;); const response = await fetch(&#39;http://192.168.1.132:5002/stream_generate_audio&#39;, { method: &#39;POST&#39;, headers: { &#39;Content-Type&#39;: &#39;application/json&#39; }, body: JSON.stringify({ prompt: document.getElementById("prompt").value }) }); const reader = response.body.getReader(); // 实时接收并播放音频流 while (true) { const { done, value } = await reader.read(); if (done) { mediaSource.endOfStream(); resolve(); break; } // 等待缓冲区可用 await new Promise((resolve) => { if (!sourceBuffer.updating) { resolve(); } else { sourceBuffer.addEventListener(&#39;updateend&#39;, resolve, { once: true }); } }); // 追加音频数据 sourceBuffer.appendBuffer(value); // audioPlayer.play(); // 自动开始播放 if (first) { audioPlayer.play(); first = false; } } } catch (error) { console.error(&#39;播放错误:&#39;, error); mediaSource.endOfStream(); } }); }); } </script> </body> </html>
03-15
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值