如果设置了弹出窗口阻拦,在Flash中打开链接,会被拦住,这对在Flash中嵌入广告不是一个好消息,好在可以通过iframe hack可以绕过这一限制,昨天折腾了大半天,总算搞定了。至于iframe hack的原理是什么,不需要明白,我们只需要吃鸡蛋,不用管鸡长的什么样子。有几个Flash lib 封装了iframe hack,如收费的flexcapacitor和免费的 flex-iframe

使用flex-iframe之后,解决起来就很简单了:

(1)首先,设置 flash 程序的属性 wmode 为 transparent ,这样flash程序就挡不住iframe层了,否则的话,动一下flash,iframe层就看不见了。

(2)接下来,我们建一个广告的容器,假设是继承自VBox的class Ad,在Ad中放一个IFrame进去,IFrame连向广告页面,这里做演示用,就直接连向www.google.com了:

<?xml version="1.0" encoding="utf-8"?>
<mx:VBox xmlns:fx="http://ns.adobe.com/mxml/2009"
         xmlns:mx="library://ns.adobe.com/flex/mx"
         width="400" height="300"
         xmlns:code="http://code.google.com/p/flex-iframe/"
         >
    <fx:Declarations>
        <!-- Place non-visual elements (e.g., services, value objects) here -->
    </fx:Declarations>
    <code:IFrame >
    </code:IFrame>
</mx:VBox>

当需要显示时show一下,需要隐藏时hide一下即可。当然,您也可以给Ad加一个属性进行绑定。

相关文章:

  • 2021-07-31
  • 2021-11-30
  • 2021-11-30
  • 2022-12-23
  • 2022-12-23
  • 2021-06-14
  • 2021-12-10
猜你喜欢
  • 2021-11-11
  • 2022-12-23
  • 2022-12-23
  • 2021-11-30
  • 2021-06-17
  • 2022-12-23
  • 2022-12-23
相关资源
相似解决方案