2011-05-04 5 views
0

가능한 중복 :
flash javascript don't work플래시

자바 스크립트 :

function getFlashMovieObject(movieName) 
{ 
    if (window.document[movieName]) 
    { 
     return window.document[movieName]; 
    } 
    if (navigator.appName.indexOf("Microsoft Internet")==-1) 
    { 
    if (document.embeds && document.embeds[movieName]) 
     return document.embeds[movieName]; 
    } 
    else // if (navigator.appName.indexOf("Microsoft Internet")!=-1) 
    { 
    return document.getElementById(movieName); 
    } 
} 

function TestPlay() 
{ 
    var flashMovie=getFlashMovieObject("myFlashPlayer"); 
    try 
    { 
     document.getElementById("TimeDisplay").innerHTML=flashMovie.GetDuration(); 
    } 
    catch(e) 
    { 
     alert(e.message); 
    } 
} 

HTML :

<object width="150" height="100" id="myFlashPlayer"> 
<param name="movie" value="Sound.swf"/> 
<embed src="Sound.swf" width="150" height="100" name="myFlashPlayer"> 
</embed> 
</object> 
<button onclick="TestPlay()" id="TestBtnPlay">Play</button> 
<span id="TimeDisplay"></span> 

2.0 :

_global.track=new Sound(); 
_global.track.onLoad=finished; 
_global.track.loadSound(Path.text,true); 
_global.last_position=0; 
_global.track.stop(); 

ExternalInterface.addCallback("GetDuration", GetDuration); 
stop(); 

function finished() 
{ 
_global.track.stop(); 
} 

function GetDuration() 
{ 
    return _global.track.duration; 
} 
+0

http://tinyurl.com/so-hints을 당신은 원래의 질문을 수정해야 –

+0

: [작동하지 않는 자바 스크립트 플래시 (HTTP를 : //stackoverflow.com/questions/5495497/flash-javascript-dont-work) – Orbling

+0

나는 그것이 새로운 질문이되기를 원했기 때문에 다른 부분을 가지고 갔다. – unicorn

답변

0

이 시도 :

function TestPlay() 
{ 
    try 
    { 
     document.getElementById("TimeDisplay").GetDuration(); 
    } 
    catch(e) 
    { 
     alert(e.message); 
    } 
} 
+0

이것은 이해가되지 않는다. GetDuration은 플래시 기능이고 TimeDisplay이다. 그것은 HTML 요소입니다. 왜이 일을해야합니까 ?? – unicorn

+0

모든 의미가 있습니다. 그 줄에서 당신이하고있는 일은 당신의 플래시 객체 id = "TimeDisplay"를 얻으려는 것입니다. 일단 당신이 당신의 플래시 객체를 가지고 있다면 "ExternalInterface.addCallback ("GetDuration ", GetDuration);"을 사용하여 노출 한 함수에 접근하면됩니다. AS2 참조를보십시오 : http://flash-reference.icod.de/ – nelsond8

+0

1. 내 falsh id는 "myFlashPlayer"입니다. 아마 – unicorn