这个问题发生的是IE8和IE7。我有一个用flex编译的小swf。它基本上只是音频流功能的一个包装。所有的控件和这些都在与JavaScript的HTML。我使用swfobject的“静态”方法加载swf。这在Firefox和Chrome中非常有用。在IE中,swf加载正确,但只要我尝试使用它流式传输任何音频,就会出现错误。IE不让闪存流音频
编辑:我已经减少了相当多的代码,试图找到问题。您可以看到运行here的新版本。以下是错误,HTML和Flex文件我的简化版本:
TypeError: Error #1009: Cannot access a property or method of a null object reference.
at isolated/playStream()[/home/defrex/code/bd/trunk/ackbar/media/flex/isolated.mxml:19]
at Function/http://adobe.com/AS3/2006/builtin::apply()
at flash.external::ExternalInterface$/_callIn()
at <anonymous>()
的HTML:
<!DOCTYPE html>
<html>
<head>
<title>fuie</title>
<script type="text/javascript" src="swfobject.js"></script>
<script>
var player;
swfobject.registerObject("_mediaplayer", "9.0.0", undefined, function(e){
if (e.success)
player = e.ref;
else
console.log('Flash not loaded');
});
</script>
</head>
<body>
<a href="#" onclick="player.play_fuie('celebration.mp3');return false;">play track</a>
<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" width="1" height="1" id="_mediaplayer">
<param name="movie" value="isolated.swf" />
<!--[if !IE]>-->
<object type="application/x-shockwave-flash" data="isolated.swf" width="1" height="1">
</object>
<!--<![endif]-->
</object>
</body>
</html>
和Flex:
<?xml version="1.0" encoding="utf-8"?>
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" layout="absolute" creationComplete="init()">
<mx:Script>
import flash.external.ExternalInterface;
import flash.media.Sound;
import flash.media.SoundChannel;
import flash.net.URLRequest;
public function init():void {
ExternalInterface.addCallback("play_fuie", playStream);
ExternalInterface.call("console.log('flash loaded')");
}
public function playStream(stream:String):void {
var url:URLRequest = new URLRequest(stream);
var audio:Sound = new Sound();
audio.load(url);
var chan:SoundChannel = audio.play();
chan.soundTransform.volume = 0.5;
}
</mx:Script>
</mx:Application>
我编辑了这个问题来显示这个,但是这个函数是通过ExternalInterface调用的。它以JavaScript的字符串形式传入。 – defrex 2009-12-11 15:34:42
我只是遇到了这个(有些痛苦,因为我也使用应该在mac上运行的外部接口)。 http://livedocs.adobe.com/flash/9.0/ActionScriptLangRefV3/flash/external/ExternalInterface.html 使用ExternalInterface类的浏览器和操作系统的组合: 浏览器操作系统操作系统 Internet Explorer 5.0中后来的Windows 的Netscape 8.0及更高版本Windows MacOS的 的Mozilla 1.7.5及更高版本Windows MacOS的 Firefox 1.0及更高版本Windows MacOS的 的Safari 1.3及更高版本的MacOS 所以如果你在Mac上运行的可能是一个问题。 – Eran 2009-12-11 16:14:54
mabe这将有助于: http://stackoverflow.com/questions/1166079/externalinterface-not-working-in-ie – Eran 2009-12-11 16:26:44