- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我很少在AS3 / Flash中使用声音。我正在使用Flash Pro CS6,但似乎无法弄清楚如何访问,控制(播放,停止等)嵌入在主SWF中的外部SWF中嵌入的声音。
嵌入到主swf中时,很容易控制它们。但是,在外部加载的SWR上,我会遇到各种错误。对于此应用程序,我确实需要将它们嵌入外部SWF中。
我阅读了几种解决方案,但似乎都没有用。
我使用Flash CS6导入工具将声音嵌入了一个名为soundSegment1.mp3的mp3文件,然后打开Flash上的actionscript属性面板以选择类名称:SoundSegment1。然后,我编辑类代码并创建一个名为SoundSegment1.as的文件,并将其保存在我的文档类main.as旁边的同一目录中。 SoundSegment1类的代码如下所示:
package {
import flash.media.*;
public class SoundSegment1 extends Sound
{
public function SoundSegment1 ()
{
// no code in here
}
public function playSound()
{
var soundSegment1:Sound = new SoundSegment1();
var channel:SoundChannel = soundSegment1.play();
}
}
}
var fileLocation:URLRequest = new URLRequest(SWFToLoad);
loader.load(fileLocation);
loader.contentLoaderInfo.addEventListener(ProgressEvent.PROGRESS, progressListener);
loader.contentLoaderInfo.addEventListener(Event.COMPLETE, completeListener);
loader.contentLoaderInfo.addEventListener(Event.INIT, initListener);
function initListener(e:Event):void // I also placed this code on the completeListener and it didn't work
{
loader.content.soundSegment1.playSound(); // doesn't work.
}
Line XXX 1061: Call to a possibly undefined method playSound through a reference with static type flash.display:DisplayObject.
var theClass:Class = Class(loader.content.getDefinitionByName("SoundSegment1"));
var theSound:theClass = new theClass();
theSound.play() //doesn't work either.
var TheClass:Class = e.target.applicationDomain.getDefinition("SoundSegment1") as Class;
var theSound:TheClass = new TheClass();
theSound.play() //doesn't work either.
ReferenceError: Error #1065: Variable SoundSegment1 is not defined.
at flash.system::ApplicationDomain/getDefinition()
最佳答案
来自Kirupa的用户SnickelFritz用简单得多的代码给了我一个神话般的答案,当使用多种声音时,这可能非常强大。这非常好,因为每个SWF只能使用一个预加载器,而不是每个文件使用多个加载器:
main.as文件的代码
http://www.kirupa.com/forum/showthread.php?305098-Playing-a-embedded-sound-in-an-external-swf
package
{
import flash.display.*;
import flash.media.*;
import flash.events.*;
import flash.net.*;
public class Main extends MovieClip
{
var swf:MovieClip;
public function Main()
{
var l:Loader = new Loader();
l.contentLoaderInfo.addEventListener(Event.COMPLETE, swfLoaded);
l.load( new URLRequest("child.swf") );
}
private function swfLoaded(e:Event):void
{
swf = e.target.content as MovieClip;
addChild(swf);
swf.playSound();
}
}
}
package
{
import flash.display.*;
import flash.media.*;
import flash.events.*;
import flash.net.*;
public class Child extends MovieClip
{
private var s:Sound1;
private var sc:SoundChannel;
public function Child()
{
s = new Sound1();
sc = new SoundChannel();
// All of the following lines are actually optional, if all your graphic elements are already inside the swf prepared in flash pro
var g:Graphics = this.graphics;
g.beginFill(0x666666);
g.drawRect(0,0,550,400);
g.endFill();
}
public function playSound():void
{
sc = s.play();
}
}
}
关于actionscript-3 - AS3:如何访问和控制外部SWF中的嵌入式声音?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/18798233/
我正在评估 Amazon SWF 作为构建分布式工作流系统的选项。主要语言将是 Java,因此 Flow 框架是一个显而易见的选择。只有一件事让我感到困惑,在我推荐它作为我们架构中的关键组件之前,我会
我在将我的 swf 文件置于另一个 swf 文件之上时遇到问题。我在这里尝试了解决方案: http://jsfiddle.net/j08691/ezXjx/ #a { position
我正在处理一个项目,我需要打开一个 swf 文件,更改 swf 标签的内容 不接触其他标签 我试过“SwfDotNet 库”,但它不输出未知标签。例如,如果它遇到“EXPORTASSETS”标签,它不
希望这不会被视为两次问同样的问题...... 所以我正在开发一个 Flash 网站(在 AS2 中),它有一个外部索引 swf,它使用 loadMovie("subfoo1.swf", placeTo
我在使用 Flash 和 Flex 时遇到了一个非常奇怪的问题。在某些情况下,如果同时加载了另一个 SWF,则在运行时(使用 Loader)加载的 SWF 中的影片剪辑似乎无法实例化。这是重现错误的程
当我创建暂时隐藏在选项卡中的 SWF 对象时,因此在某些浏览器(如 FireFox)中未完全加载,我似乎无法找到方法来确定 SWF 是否已加载,因此我可以与它。 /* Generate SWF (on
我加载了一个外部 SWF。 外部 SWF 有一个嵌入的 DisplayObject (getChildAt(0)) 我得到了它的 Class 实例以下代码: public function g
这是一个更一般的问题,而不是“帮助修复代码”问题: 目标 父 swf a.swf 加载外部子 b.swf 子 swf 有跟踪语句:[timestamp][log level][class] msg 父
我想在显示swf文件的webview中显示另一个swf文件,并且我可以获取显示swf文件的路径,但是当我将另一个swf文件拖放到显示swf文件的webview时,swf文件无法获取打不开,为什么?以及
目标:无需 www.macromedia.com/support/documentation/上的任何特殊权限,即可从本地协议(protocol)(widget://、file://、chrome-e
我正在尝试通过 CSS(绝对定位)将透明 PNG 定位在 SWF 影片上。但是,当我将 PNG 直接放在 SWF 上时,SWF 上的所有单击操作似乎都被禁用了。 SWF 要求使用您的网络摄像头,但您无
我想知道是否有人知道以编程方式创建 Flash swf 文件的任何库。 或者用于从 svg 创建 swf。 最佳答案 这听起来对 swfmill 来说是一份完美的工作我想您会发现它可以让您同时执行两种
我有一个加载其他几个 swf 的主要“父” swf。如果主 swf 发生了什么事,我需要告诉其中一个子 swf。 反过来,这似乎效果很好。任何 child 都可以简单地 dispatchEvent()
概览: 我有一个 SWF 横幅广告模板,它从我开发的平台加载 JSON,然后循环浏览该 JSON 中指定的一些产品。每个产品都由您的标准标题、价格和图像组成。 在平台上,用户可以通过一些 UI 工具(
我一直在努力让 AS2 swf 在 AS3 swf 中正确加载 - 但没有成功... AS2 文件(这是一个相当大的应用程序,引用许多外部 xml 文件等)在 Flash Player 中启动时可以完
我正在尝试做这样的事情:拿一个 swf 文件损坏它,然后..在设备内部再次将其可读(未损坏)...我将使用我自己编写的设备指纹检查该设备是否可以恢复 swf.. 得到? 我可以这样做吗?有什么办法呢?
我需要从一些 swf 文件中提取所有文本。我使用 Java 是因为我有很多用这种语言开发的模块。因此,我在 Web 上搜索了所有专门用于处理 SWF 文件的免费 Java 库。最后,我找到了Stuar
我认为这个问题不言自明。以前有人这样做过吗? 更新:澄清我为什么需要这样做。我们有一个 AS1 - AS2 站点的单一 swf 庞然大物,带有大型视频库部分。客户想要更新视频部分,因为 AS2 代码无
有没有人成功使用过 [Flagstone Software][1] 的 Transform SWF for Java 库 [1]: http://www.flagstonesoftware.com/t
例如,隐藏一个简单的 youtube 嵌入 document.getElementById('youtube').style.display = 'block'; document.getElemen
我是一名优秀的程序员,十分优秀!