views:

304

answers:

3

This problem is happening is both IE8 and IE7. I have a small swf compiled with flex. It's basically just a wrapper around audio streaming functionality. All the controls and such are in html with javascript. I load the swf using swfobject's "static" method. This works great in Firefox and Chrome. In IE, the swf loads correctly, but as soon as I try to stream any audio with it, I get an error.

EDIT: I've reduced the code quite a bit to try and find the problem. You can see the new version running here. Here is the error, html and flex files for my reduced version:

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>()

The 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>

And the 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>
A: 

Its hard to see in your code how stream is passed to flash , if it is from your flash params keep in mind that ie and firefox have different syntax to passing parameters to flash object

http://www.cflex.net/showFileDetails.cfm?ChannelID=1&amp;Object=File&amp;ObjectID=285

Eran
I've edited the question to show this, but the function is called via ExternalInterface. It's passed in as a string from JavaScript.
defrex
I just run into this ( with some surpeise since i also use external interfaces that should run on mac ).http://livedocs.adobe.com/flash/9.0/ActionScriptLangRefV3/flash/external/ExternalInterface.htmlUse the ExternalInterface class in the following combinations of browser and operating system:Browser Operating System Operating System Internet Explorer 5.0 and later Windows Netscape 8.0 and later Windows MacOS Mozilla 1.7.5 and later Windows MacOS Firefox 1.0 and later Windows MacOS Safari 1.3 and later MacOS so if you are running on mac might be an issue .
Eran
mabe this will help :http://stackoverflow.com/questions/1166079/externalinterface-not-working-in-ie
Eran
Eran, this all works great on macs, and I'm using the reference to the player specifically passed to me from swfobject in the "object loaded" event. The reference is working, since I'm getting an error back from flash from inside the called method.
defrex
Sorry its not helping , i still think your flash code is fine , the fact that the flash function is called does not neccesarly mean the stream parameter is passed correctly ( it sounds like you are passing null there ) . also because only on ie you get the error it is very likely your error is in the javascript
Eran
A: 

After 3 frustrating days if debugging, the moral of the story: software piracy is bad. As it turns out the sketchy "XP Pirate Edition" that was passed around the dev team for IE testing in VirtualBox had some kind of bug (or perhaps malware) that was causing the issue. When we tried the test in Chrome installed in the same VM and it came up with the same error (while Chromium under Linux was working beautifully), we realized that there might be something wrong with the OS. Sure enough, when we got our hands on a legitimate version of IE everything worked perfectly.

Karma can be cruel.

defrex
A: 

TXH YOU FOR THIS ANSWER. WE ARE DEBUGGING SINCE 3 hours for this shit of VirtualBox. In a clean version of the IE everthing working perfectly

Steffen
I appreciate the thanks. Feel free to vote.
defrex