IE8和IE7都出现这个问题。我有一个用 flex 编译的小 swf。它基本上只是围绕音频流功能的包装。所有控件等都在带有 javascript 的 html 中。我使用 swfobject 的“静态”方法加载 swf。这在 Firefox 和 Chrome 中效果很好。在 IE 中,swf 加载正确,但是一旦我尝试使用它流式传输任何音频,就会出现错误。
编辑:我已经减少了很多代码来尝试找到问题。您可以在此处看到正在运行的新版本。这是我简化版本的错误、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>
和弹性:
<?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>