[Flash动画制作技巧]Flash 视频广告的定位兼容性问题

分类:Flash动画制作    发布时间:2017年06月06日    点击:1239次

  调用代码如下:

  视频广告:

  ×

  大型XX活动

  flash.js代码(修改后的)如下:

  if(document.all){

  window.attachEvent('onload',getMsg);

  }else{

  window.addEventListener('load',getMsg,false);

  }

  window.onresize = resizeDiv;

  window.onerror = function(){}

  var divTop,divLeft,divWidth,divHeight,docHeight,docWidth,objTimer,i = 0;

  function getMsg()

  {

  try{

  var eMeng = document.getElementById("eMeng");

  /* 为修改前

  var docWidth = document.documentElement.clientWidth;

  var docHeight = document.documentElement.clientHeight;

  */

  //修改后:

  var docWidth = getWidth();

  var docHeight = getHeight();

  divTop = parseInt(eMeng.style.top,10);

  divLeft = parseInt(eMeng.style.left,10);

  divHeight = parseInt(eMeng.offsetHeight,10);

  divWidth = parseInt(eMeng.offsetWidth,10);

  eMeng.style.top = parseInt(document.documentElement.scrollTop,10) + docHeight + 10+"px" ;// divHeight

  eMeng.style.left = parseInt(document.documentElement.scrollLeft,10) + docWidth - divWidth+"px" ;

  eMeng.style.visibility = "visible";

  objTimer = window.setInterval("moveDiv()",10)

  }catch(e){

  }

  }

  function resizeDiv()

  {

  i+=1;

  try{

  var eMeng = document.getElementById("eMeng");

  var docWidth = getWidth();

  var docHeight = getHeight();

  divHeight = parseInt(eMeng.offsetHeight,10)

  divWidth = parseInt(eMeng.offsetWidth,10)

  eMeng.style.top = docHeight - divHeight + parseInt(document.documentElement.scrollTop,10)+"px" ;

  eMeng.style.left = docWidth - divWidth + parseInt(document.documentElement.scrollLeft,10)+"px" ;

  }catch(e){}

  }

  function moveDiv()

  {

  try

  {

  var eMeng = document.getElementById("eMeng");

  var docWidth = getWidth();

  var docHeight = getHeight();

  divHeight = parseInt(eMeng.offsetHeight,10);

  divWidth = parseInt(eMeng.offsetWidth,10);

  if(parseInt(eMeng.style.top,10) <= (docHeight - divHeight + parseInt(document.documentElement.scrollTop,10)))

  {

  window.clearInterval(objTimer);

  objTimer = window.setInterval("resizeDiv()",1);

  }

  divTop = parseInt(eMeng.style.top,10);

  divTop--;

  eMeng.style.top = divTop+"px" ;

  }catch(e){

  }

  }

  function closeDiv()

  {

  var eMeng = document.getElementById("eMeng");

  eMeng.innerHTML='';

  eMeng.style.visibility='hidden';

  if(objTimer) window.clearInterval(objTimer);

  }

  /**

  * 获取屏幕宽度的函数,在非xhtml标准页面下有可能有问题

  */

  function getWidth()

  {

  var winWidth = '';

  if (window.innerWidth)//for Firefox

  {

  winWidth = window.innerWidth;

  }

  else if((document.body) && (document.body.clientWidth))

  {

  winWidth = document.body.clientWidth;

  }

  if (document.documentElement && document.documentElement.clientWidth)

  {

  winWidth = document.documentElement.clientWidth;

  }

  return winWidth;

  }

  /**

  * 获取屏幕高度的函数

  * html,body高度属性必须设值为height:100%否则在火狐浏览器下获取不到真实高度

  */

  function getHeight()

  {

  var winHeight = '';

  if (window.innerHeight)//for Firefox

  {

  winHeight = window.innerHeight;

  }

  else if((document.body) && (document.body.clientHeight))

  {

  winHeight = document.body.clientHeight;

  }

  if (document.documentElement && document.documentElement.clientHeight)

  {

  winHeight = document.documentElement.clientHeight;

  }

  return winHeight;

  }

  *:红色部分为修改的位置或添加的代码

  修改部分:

  1.增强型的获取窗口长度和宽度的函数;

  2.在style.top,style.left等处在Firefox下必须使用单位px;

  3.调整 Flash参数之wmodel,即window model,详情请自己搜索;

  修改以上几处,就可以实现IE,Firefox的准确定位和相同的显示效果。

推荐阅读:

东风本田安全生产系列宣传片动画制作

4月番《重启咲良田》新宣传图公布 狂野少女加盟

教育公益动画制作:先锋王能干成品

最近发表
标签列表