2013-03-30 6 views
1

학교 작업 (dreamfoxgames.com)으로 웹 사이트를 구축 중입니다.버튼을 누른 후 플래시로드

"재생"버튼을 클릭하면 팝업/모달이 플래시 또는 유니티 플러그인으로 게임과 함께 제공됩니다. 내 문제는 방문자가 페이지를로드 할 때 자동으로 플래시 파일을로드한다는 것입니다. 즉, 음악이 시작되고 페이지가로드 될 때 느려집니다 (모든 게임).

누군가가 재생 버튼을 누른 후 플래시 플레이어 만로드 할 수있는 방법이 있습니까?

고마워요!

+0

예, 페이지가 준비되면 ajax 호출로 필요한 html로드 (플래시 사용) – Maresh

답변

0

) :

<!DOCTYPE html> 
<html> 
<head> 
<title></title> 
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8"> 
<script type="text/javascript"> 
    var flashEmbed = null; 
    function startFlash() { 
    if(flashEmbed != null) { 
     document.getElementById("flashContainer").removeChild(flashEmbed); 
    } 
    flashEmbed = document.createElement("embed"); 
    document.getElementById("flashContainer").appendChild(flashEmbed); 
    flashEmbed.src="Flashfile.swf"; 
    flashEmbed.type="application/x-shockwave-flash"; 
    } 
</script> 
</head> 
<body> 
<button onclick="startFlash()">start flash</button> 
<div id="flashContainer"></div> 
</body> 
</html> 
+0

고마워, 유일한 문제는 누군가가 버튼을 눌렀을 때 매번 새로운 플래시가 삽입된다는 것이다. – SaschaDeWaal

+0

한 번에 하나 이상의 소스 코드가 삽입되지 않도록 코드를 수정했다. –

0

swfobject을 사용하여 div에 swf 콘텐츠를로드 할 수 있습니다.

당신은 SWF를 재생하려면

<!DOCTYPE html> 
<head> 
    <script src="//ajax.googleapis.com/ajax/libs/swfobject/2.2/swfobject.js"></script> 
    <script> 
</head> 
<body> 
     <div id="myContent"> 
     swf will be embedded here 
     </div> 
    <button onclick="playSwf()">Click to play swf</button> 
</body> 
</html> 

아래로 HTML의 사업부가있는 경우 가정 ..

<script type="text/javascript"> 
    function playSwf() 
    { 
     //Syntax 
     //swfobject.embedSWF(swfUrl, id, width, height, version, 
     //     expressInstallSwfurl, flashvars, params, 
    //      attributes, callbackFn) 

     //optional parameters omitted 
     swfobject.embedSWF("test.swf", "myContent", "400", "400","10"); 

    } 
    </script> 
그것은 또한 embed 요소 (외부 API에 대한 필요성을 사용하여 수행 할 수 있습니다
+0

감사합니다! 그러나 어떤 이유에서이 코드는 부트 스트랩으로 정말 잘 작동하지 않습니다. – SaschaDeWaal

관련 문제