ExternallInterface и swfobject 2.2 не работают в IE

27 views
Skip to first unread message

dima.be...@gmail.com

unread,
Nov 17, 2009, 12:54:07 PM11/17/09
to ruFlash
Выпадает ошибка
Object doesn't support this property or method

В остальных браузерах всё ок.
Пол дня бьюсь не могу понять, что такое. Подскажите.

Код флешки

package {
import flash.display.Sprite;
import flash.events.Event;
import flash.events.IOErrorEvent;
import flash.events.ProgressEvent;
import flash.external.ExternalInterface;
import flash.media.Sound;
import flash.media.SoundChannel;
import flash.net.URLRequest;

public class MicroPlayer extends Sprite {
private var sound : Sound;
private var channel:SoundChannel = new SoundChannel();

public function MicroPlayer() {
if (ExternalInterface.available) {
try {
ExternalInterface.addCallback('play', startPlaying);
ExternalInterface.addCallback('stop', stopPlaying);
}
catch (error:SecurityError) {
throw error;
} catch (error:Error) {
throw error;
}


}
}

private function stopPlaying() : void {
channel.stop();
}

private function startPlaying(url : String) : void {
sound = null;
sound = new Sound();
sound.addEventListener(IOErrorEvent.IO_ERROR, onErrorHandler);
sound.addEventListener(ProgressEvent.PROGRESS, onProgress);
try {
sound.load(new URLRequest(url));
channel = sound.play();
channel.addEventListener(Event.SOUND_COMPLETE,
onSoundComplete);
}
catch(err : Error) {
onErrorHandler(null);
}
}

private function onProgress(event : ProgressEvent) : void {

}

private function onSoundComplete(event : Event) : void {
ExternalInterface.call('end');
}

private function onErrorHandler(event : IOErrorEvent) : void {
ExternalInterface.call('soundError');
}
}
}

Код страницы

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://
www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Untitled Document</title>
<!--[if IE]><script type="text/javascript" src="http://getfirebug.com/
releases/lite/1.2/firebug-lite-compressed.js"></script><![endif]-->
<script type="text/javascript" src="swfobject.js"></script>
<script>
flashVars = {};
params = {allowScriptAccess: "always"};
attributes = {};
function end () {alert("end");}

function soundError () {alert("soundError");}

function playSound() {
document.getElementById("microPlayer").play("Alenka.mp3");
}
swfobject.addDomLoadEvent(function () {swfobject.embedSWF
("MicroPlayer.swf","microPlayer","100","100","10.0.0","expressInstall.swf",flashVars,params,attributes);});
</script>
</head>

<body>
<div id="microPlayer">
</div>
<a rel="Alenka.mp3" onClick="playSound()">Play</a>

</body>
</html>

dima.be...@gmail.com

unread,
Nov 17, 2009, 2:45:21 PM11/17/09
to ruFlash
Проблема решилась.

заменой


ExternalInterface.addCallback('play', startPlaying);
ExternalInterface.addCallback('stop', stopPlaying);

на
ExternalInterface.addCallback('playSound', startPlaying);
ExternalInterface.addCallback('stopSound', stopPlaying);

Оказалось, что для флешки в IE нельзя добавлять метод play, наверное,
уже есть такой.
Ввело в заблуждение, то что во всех других браузерах всё работало ок.

foreground

unread,
Nov 18, 2009, 1:29:02 AM11/18/09
to ruf...@googlegroups.com
> dima.be...@gmail.com:
> Проблема решилась.

У нас такой же косяк постоянно получается. И дело не в названиях
методов. Что делать не понятно. Есть версия, что проблема в очистках
кэша и антивирусе или и вовсе в плагине.

dima.be...@gmail.com

unread,
Nov 18, 2009, 8:46:35 AM11/18/09
to ruFlash

> У нас такой же косяк постоянно получается. И дело не в названиях
> методов. Что делать не понятно. Есть версия, что проблема в очистках
> кэша и антивирусе или и вовсе в плагине.

Оказывается не решилась. Вчера всё работало. Сегодня уже нет.
Чертовщина, какая-то.

Пробовали отлаживать Визуал студией, она хорошо показывает
динамический код создаваемый, в ИЕ.
Обычно проблема возникала, на этапе добавления коллбека. А теперь
каждый раз в разных местах.

Alexey Hodkov

unread,
Nov 20, 2009, 8:25:39 AM11/20/09
to ruf...@googlegroups.com
Мне кажется дело в html.

getElementById("microPlayer") обращается к диву. А нужен еще id у самого объекта в параметрах (к которому обращение будет).
И эти id должны быть разными.
Reply all
Reply to author
Forward
0 new messages