2015-09-02 52 views
0

我試圖從swift轉換後的swf中將doubleclick studio中的退出網址和指標添加到HTML5文件中。 任何人都可以告訴我最有效的方法是做什麼?代碼在HTML5廣告素材中的外觀如何?哪裏在代碼中添加最好?要使用哪些標籤? swiffy生成的代碼對我來說看起來很亂。用swiffy退出swf轉換後的URL

<!doctype html> 
<html> 
    <head> 

    <script src="https://s0.2mdn.net/ads/studio/Enabler.js"> </script> 
    <link rel="stylesheet" type="text/css" href="exit.css"> 
    <script src="exit.js"></script> 


    <meta charset="utf-8"> 
    <meta http-equiv="X-UA-Compatible" content="IE=edge"> 
    <title>Swiffy Output</title> 
    <script type="text/javascript" src="https://www.gstatic.com/swiffy/v7.3.0/runtime.js"></script> 

    <script> 
     swiffyobject = {"as3":true,"frameRate":25,"frameCount":342,"backgroundColor":-1,"frameSize":{"ymin":0,"xmin":0,"ymax":1800,"xmax":19400},"fileSize":52767,"v":"7.3.0","internedStrings":["::::::6Y:","::::: <<shortend from here>> 

    </script> 
    <style>html, body {width: 100%; height: 100%}</style> 
    </head> 
    <body style="margin: 0; overflow: hidden"> 

    <div id="swiffycontainer" style="width: 970px; height: 90px"> 
    </div> 

    <script> 

     var stage = new swiffy.Stage(document.getElementById('swiffycontainer'), 
      swiffyobject, {}); 

     stage.start(); 
    </script> 
    </body> 
</html> 

回答

1

這是對this answer的附加/改進。

所以,你會在你的HTML5文件夾中的幾個文件(,你會打包成zip在構建過程結束上傳到DoubleClick Studio)

  • 的index.html
  • styles.css的
  • backupimage(* .gif要點/ * .JPG)
  • Ajax的loader.gif(我使用這個作爲佔位符時元件仍在加載
  • object.js(其中轉換Swiffy與代碼會
  • 的script.js(當魔術發生

的backupimage是圖像,你應該表現出公正的情況下沒有按創作無法加載,而且ajax-loader.gif可以在線獲得。所以我們將關注其他4個文件。


的index.html

<html lang="en-US"> 
    <head> 
     <meta charset="UTF-8"> 
     <title>[ Creative Name ]</title> 
     <meta name="ad.size" content="width=300,height=250"> 

     <link rel="stylesheet" type="text/css" href="styles.css" media="all"> 

     <script type="text/javascript" src="https://s0.2mdn.net/ads/studio/Enabler.js"></script> 

     <!-- Make sure that this is the most recent runtime.js from the Swiffy Conversion file --> 
     <script type="text/javascript" src="https://www.gstatic.com/swiffy/v7.3.0/runtime.js"></script> 
     <script src="object.js"></script> 
     <script src="script.js"></script> 
    </head> 

    <body> 
     <div id="swiffycontainer" class="loading"></div> 
     <div id="bg-exit"></div> 
    </body> 
</html> 

styles.css的

* { 
    border:0; 
    padding:0; 
    margin:0; 
} 

body, html { 
    width:100%; 
    height:100%; 
    overflow:hidden; 
    background:#fff; 

    width:100%; 
    height:100%; 

    position:relative; 
} 

#bg-exit { 
    position:absolute; 
    z-index:999999; 
    left:0; 
    top:0; 
    width:100%; 
    height:100%; 
    overflow:hidden; 
    cursor: pointer; 
} 

#swiffycontainer { 
    position:absolute; 
    z-index:100; 
    width:100%; 
    height:100%; 
    overflow:hidden; 
} 

#swiffycontainer.loading { 
    background: url("ajax-loader.gif") center center no-repeat; 
} 

objects.js

複印無論從Swiffy與轉換和輸出粘貼到{}如下所示

var swiffyobject = { 
"as3":false,"frameRate":24,"frameCount":114,"backgroundColor":-1,"frameSize":{" .... blah blah blah blah }] 
}; 

scripts.js中

var stage; 
var clickTag; 

if (!Enabler.isInitialized()) { 
    Enabler.addEventListener(
     studio.events.StudioEvent.INIT, 
     enablerInitialized 
    ); 
} else { 
    enablerInitialized(); 
} 

function enablerInitialized() { 
    if (!Enabler.isVisible()) { 
     Enabler.addEventListener(
      studio.events.StudioEvent.VISIBLE, 
      adVisible 
     ); 
    } else { 
     adVisible(); 
    } 

} 

function adVisible() { 
    document.getElementById('swiffycontainer').className = ""; 
    document.getElementById('bg-exit').addEventListener('click', exitHandler, false); 

    stage = new swiffy.Stage(document.getElementById('swiffycontainer'), swiffyobject, {}); 
    stage.start(); 
} 

function exitHandler(e) { 
    Enabler.exit('Exit'); 
} 

使用上述操作爲我和我的所有廣告素材執行上述操作代碼已經被谷歌的質量保證部門批准,現在正在被販運 - 所以我對我的回答非常有信心 - 雖然再次,這只是從this answer的改進。