ExternalInterface.addCallback does not work in IE8 Flash 10.0 or lower

I have a small flash application that I dynamically download via jQuery document.ready. It works in all browsers except IE. When the installed version of FlashPlayer is less than 10.1, callbacks added through addCallBack are missing. I compiled the application with mxmlc in flex 3.5, which target player is 9.0.124, so it should work. I created other more flexible applications and had no problems with ExternalInterface and IE. The application loads, and the ExternalInterface.call method fires and IE answers, but there are simply no callbacks. Errors do not occur.

Myapp.as

public class MyApp extends Sprite { private var sounds:Dictionary = new Dictionary(); private var channel:SoundChannel = new SoundChannel(); private var onLoadHandler:String; public function MyApp() { flash.system.Security.allowDomain("*"); var flashvars:Object = LoaderInfo(this.root.loaderInfo).parameters; onLoadHandler = flashvars.onLoad; addEventListener(Event.ENTER_FRAME, registerExternalCallbacks); } private function registerExternalCallbacks(event:Event):void{ removeEventListener(Event.ENTER_FRAME, registerExternalCallbacks); if (ExternalInterface.available) { ExternalInterface.addCallback("addSound", addSound); ExternalInterface.addCallback("playSound", playSound); ExternalInterface.addCallback("getCameraCount", getCameraCount); if (onLoadHandler) { ExternalInterface.call(onLoadHandler); } } }; private function addSound(name:String, url:String):void{ var sound:Sound = new Sound(); sound.load(new URLRequest(url)); sounds[name] = sound; } private function playSound(name:String):void{ if (sounds[name] != null) { channel = sounds[name].play(); } } private function getCameraCount():int { return Camera.names.length; } } 

HTML markup

 <object width="1" height="1" id="MyApp" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=9,0,0,0" classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" style="position: absolute; top: -999px; left: -999px;"> <param value="MyApp.swf" name="movie"> <param value="always" name="allowScriptAccess"> <param value="false" name="allowFullScreen"> <param value="false" name="loop"> <param value="false" name="menu"> <param value="high" name="quality"> <param value="onLoad=onLoad" name="flashvars"> <embed width="1" height="1" flashvars="onLoad=onLoad" quality="high" menu="false" loop="false" allowfullscreen="false" allowscriptaccess="always" name="MyApp" src="MyApp.swf" pluginspage="http://www.macromedia.com/go/getflashplayer" swliveconnect="true" type="application/x-shockwave-flash"> </object> 

Ideally, I would not worry too much, but my boss would like this to work for older flash versions, so our customers are forced to update.

+1
source share

Source: https://habr.com/ru/post/927165/


All Articles