관련글 : 2008/01/24 - [이럴땐, 이렇게!/프로그래밍] - 액션스크립트 3.0과 자바스크립트 연동하기
보통, 플래시파일을 삽입할때 이올라스패치관련, 또는 사용의 간결함을 위해 자바스크립트로 삽입코드를 정의해두고 사용하는 경우가 많습니다.
function GetEmbed(url,id,width,height,vars) {
var txt = '<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" codebase="http://fpdownload.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=8,0,0,0" width="'+width+'" height="'+height+'" id="'+id+'" align="middle">';
txt+= '<param name="allowScriptAccess" value="always" />';
txt+= '<param name="flashVars" value="'+vars+'" />';
txt+= '<param name="movie" value="'+url+'" />';
txt+= '<param name="quality" value="high" />';
txt+= '<param name="wmode" value="transparent" />';
txt+= '<embed id="'+id+'" src="'+url+'" quality="high" wmode="transparent" style="width:'+width+'px; height:'+height+'px;" align="middle" allowScriptAccess="always" type="application/x-shockwave-flash" pluginspage="http://www.macromedia.com/go/getflashplayer" flashVars="'+vars+'"></embed>';
txt+= '</object>';
document.write(txt);
}
var txt = '<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" codebase="http://fpdownload.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=8,0,0,0" width="'+width+'" height="'+height+'" id="'+id+'" align="middle">';
txt+= '<param name="allowScriptAccess" value="always" />';
txt+= '<param name="flashVars" value="'+vars+'" />';
txt+= '<param name="movie" value="'+url+'" />';
txt+= '<param name="quality" value="high" />';
txt+= '<param name="wmode" value="transparent" />';
txt+= '<embed id="'+id+'" src="'+url+'" quality="high" wmode="transparent" style="width:'+width+'px; height:'+height+'px;" align="middle" allowScriptAccess="always" type="application/x-shockwave-flash" pluginspage="http://www.macromedia.com/go/getflashplayer" flashVars="'+vars+'"></embed>';
txt+= '</object>';
document.write(txt);
}
위의 소스는 제가 사용하는 소스입니다.
그런데 이렇게 사용하고 있을때, 브라우져에 따라 ExternalInterface.addCallback 을 통한 자바스크립트에서 플래시의 함수로 접근하지 못하는 경우가 있습니다.
FF에서 플래시객체를 불러오지 못하는 경우
object 와 embed 에 동시에 id 값을 지정하게 되면, FF에서는 id 값을 참조하지 못합니다. 그렇다고 object 에만 정의하면 FF에서는 object를 해석하지 않으므로 당연히 id 값을 참조하지 않고, embed 에만 id값을 정의하면 IE에서 참조하지 못하는 경우가 생기죠.
이럴땐 어쩔수 없이, 위의 소스를 분할해서 IE와 FF일경우를 정의해주면 됩니다.
function GetEmbed(url,id,width,height,vars) {
vars = vars ? vars : "";
if (isIE) {
var txt = '<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" codebase="http://fpdownload.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=8,0,0,0" width="'+width+'" height="'+height+'" id="'+id+'" align="middle">';
txt+= '<param name="allowScriptAccess" value="always" />';
txt+= '<param name="flashVars" value="'+vars+'" />';
txt+= '<param name="movie" value="'+url+'" />';
txt+= '<param name="quality" value="high" />';
txt+= '<param name="wmode" value="transparent" />';
txt+= '<embed src="'+url+'" quality="high" wmode="transparent" style="width:'+width+'px; height:'+height+'px;" align="middle" allowScriptAccess="always" type="application/x-shockwave-flash" pluginspage="http://www.macromedia.com/go/getflashplayer" flashVars="'+vars+'"></embed>';
txt+= '</object>';
document.write(txt);
} else {
txt = '<embed id="'+id+'" src="'+url+'" quality="high" wmode="transparent" style="width:'+width+'px; height:'+height+'px;" align="middle" allowScriptAccess="always" type="application/x-shockwave-flash" pluginspage="http://www.macromedia.com/go/getflashplayer" flashVars="'+vars+'"></embed>';
document.write(txt);
}
}
vars = vars ? vars : "";
if (isIE) {
var txt = '<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" codebase="http://fpdownload.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=8,0,0,0" width="'+width+'" height="'+height+'" id="'+id+'" align="middle">';
txt+= '<param name="allowScriptAccess" value="always" />';
txt+= '<param name="flashVars" value="'+vars+'" />';
txt+= '<param name="movie" value="'+url+'" />';
txt+= '<param name="quality" value="high" />';
txt+= '<param name="wmode" value="transparent" />';
txt+= '<embed src="'+url+'" quality="high" wmode="transparent" style="width:'+width+'px; height:'+height+'px;" align="middle" allowScriptAccess="always" type="application/x-shockwave-flash" pluginspage="http://www.macromedia.com/go/getflashplayer" flashVars="'+vars+'"></embed>';
txt+= '</object>';
document.write(txt);
} else {
txt = '<embed id="'+id+'" src="'+url+'" quality="high" wmode="transparent" style="width:'+width+'px; height:'+height+'px;" align="middle" allowScriptAccess="always" type="application/x-shockwave-flash" pluginspage="http://www.macromedia.com/go/getflashplayer" flashVars="'+vars+'"></embed>';
document.write(txt);
}
}
isIE라는 변수를 만들어(이건 알아서 만드셔야 합니다. ㅠ_ㅠ), IE일경우에는 object 태그에만 id 값을 정의했고, IE가 아닌경우엔 embed 태그에만 id 값을 정의해주었습니다.
이렇게 해서 문제가 모두 해결될 줄 알았지만, 우리의 친절한 IE... IE7 버전까지도 수정되지 못한 버그가 하나더 있습니다.
IE6,7 에서 FORM안의 플래시 ExternalInterface 문제
네, 우리의 망할 IE. 역시나 기대를 저버리지 않고 버그가 있습니다. 바로 form 태그안에 플래시가 삽입되어 있을경우, ExternalInterface 가 동작하지 않습니다. 이뭐병.
그럴경우 아래의 소스와 같이 해주시면 무리없이 동작합니다.
function GetEmbed(url,id,width,height,vars) {
if (isIE) {
var txt = '<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" codebase="http://fpdownload.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=8,0,0,0" width="'+width+'" height="'+height+'" id="'+id+'" align="middle">';
txt+= '<param name="allowScriptAccess" value="always" />';
txt+= '<param name="flashVars" value="'+vars+'" />';
txt+= '<param name="movie" value="'+url+'" />';
txt+= '<param name="quality" value="high" />';
txt+= '<param name="wmode" value="transparent" />';
txt+= '<embed src="'+url+'" quality="high" wmode="transparent" style="width:'+width+'px; height:'+height+'px;" align="middle" allowScriptAccess="always" type="application/x-shockwave-flash" pluginspage="http://www.macromedia.com/go/getflashplayer" flashVars="'+vars+'"></embed>';
txt+= '</object>';
document.write(txt);
eval("window." + id + " = document.getElementById('" + id + "');");
} else {
txt = '<embed id="'+id+'" src="'+url+'" quality="high" wmode="transparent" style="width:'+width+'px; height:'+height+'px;" align="middle" allowScriptAccess="always" type="application/x-shockwave-flash" pluginspage="http://www.macromedia.com/go/getflashplayer" flashVars="'+vars+'"></embed>';
document.write(txt);
}
}
if (isIE) {
var txt = '<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" codebase="http://fpdownload.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=8,0,0,0" width="'+width+'" height="'+height+'" id="'+id+'" align="middle">';
txt+= '<param name="allowScriptAccess" value="always" />';
txt+= '<param name="flashVars" value="'+vars+'" />';
txt+= '<param name="movie" value="'+url+'" />';
txt+= '<param name="quality" value="high" />';
txt+= '<param name="wmode" value="transparent" />';
txt+= '<embed src="'+url+'" quality="high" wmode="transparent" style="width:'+width+'px; height:'+height+'px;" align="middle" allowScriptAccess="always" type="application/x-shockwave-flash" pluginspage="http://www.macromedia.com/go/getflashplayer" flashVars="'+vars+'"></embed>';
txt+= '</object>';
document.write(txt);
eval("window." + id + " = document.getElementById('" + id + "');");
} else {
txt = '<embed id="'+id+'" src="'+url+'" quality="high" wmode="transparent" style="width:'+width+'px; height:'+height+'px;" align="middle" allowScriptAccess="always" type="application/x-shockwave-flash" pluginspage="http://www.macromedia.com/go/getflashplayer" flashVars="'+vars+'"></embed>';
document.write(txt);
}
}
빨간부분이 추가되었죠. FORM태그안에서 ExternalInterface 를 호출하는 시점이 문제가 생기는듯한데 정확한 원인은 MS만 알것이고, 일단은 이렇게 해결이 된다니 다행입니다.
'이럴땐, 이렇게! > 프로그래밍' 카테고리의 다른 글
| 플래시 플레이어 9.0.124 이후 원격지 소켓인증받기 (0) | 2008/07/31 |
|---|---|
| Editplus에서 C++ 컴파일러 연동 (0) | 2008/03/10 |
| ExternalInterface.addCallback 버그해결볍 (1) | 2008/02/02 |
| 액션스크립트 3.0과 자바스크립트 연동하기 (0) | 2008/01/24 |
| IE와 FF에서 똑같이 보이게 하기 위한 몇가지 팁 (29) | 2008/01/23 |
| myEolin 추천/북마크 버튼 디자인 바꾸기 (15) | 2008/01/19 |
0 Votes |
||
0 Bookmarks |







댓글을 달아 주세요
좋은 정보네요.
2008/06/22 13:43