swfobject 오픈 소스 프로젝트로 진행중이다.
http://code.google.com/p/swfobject/

웹표준에 부합하지 않는 플래시를 좋아하진 않지만, 플래시를 어쩔 수 없이 써야하는 경우가 있다. 동적인 컨텐츠를 로드한다랄지 클라이언트에서 그렇게 원한다던지…

근데 Internet Explorer와 FireFox는 서로 다른 방식으로 HTML 태그(embed, object)를 사용한다. 그리고 그 파라미터는 복잡해서 매번 컨텐츠를 넣을때마다 외울 수도 없고 항상 찾아서 넣어야 한다. swfojbect를 사용하면 이러한 불편함을 줄일 수 있고, 태그를 잘못썼나 하는 고민에서 해방될 수 있다. 그리고 무엇보다 몇줄만 추가하면 되고 스펙에 정의된대로 뿌려줄 수 있기 때문에 매우 편리하다.

기존 플래시 가져오는 코드

  1. <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
  2. <html xmlns="http://www.w3.org/1999/xhtml" lang="en" xml:lang="en">
  3.   <head>
  4.     <title>SWFObject – step 3</title>
  5.     <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
  6.     <script type="text/javascript" src="swfobject.js"></script>
  7.  
  8.     <script type="text/javascript">
  9.     swfobject.registerObject("myId", "9.0.115", "expressInstall.swf");
  10.     </script>
  11.  
  12.   </head>
  13.   <body>
  14.     <div>
  15.  
  16.       <object id="myId" classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" width="780" height="420">
  17.  
  18.         <param name="movie" value="myContent.swf" />
  19.         <!–[if !IE]>–>
  20.         <object type="application/x-shockwave-flash" data="myContent.swf" width="780" height="420">
  21.         <!–<![endif]–>
  22.           <p>Alternative content</p>
  23.         <!–[if !IE]>–>
  24.         </object>
  25.         <!–<![endif]–>
  26.       </object>
  27.     </div>
  28.   </body>
  29. </html>

swfobject 사용후 변경된코드

  1.  
  2. <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
  3. <html xmlns="http://www.w3.org/1999/xhtml" lang="en" xml:lang="en">
  4.   <head>
  5.     <title>SWFObject dynamic embed – step 3</title>
  6.     <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
  7.     <script type="text/javascript" src="swfobject.js"></script>
  8.      
  9.     <script type="text/javascript">
  10.     swfobject.embedSWF("myContent.swf", "myContent", "300", "120", "9.0.0");
  11.     </script>
  12.  
  13.   </head>
  14.   <body>
  15.     <div id="myContent">
  16.       <p>Alternative content</p>
  17.     </div>
  18.   </body>
  19. </html>

한줄로 쉽게 사용할 수 있다는게 매우 매력적이다.

Tagged with:  
Free WordPress Theme