替换Google广告(Flash AS2)中的“Math.random”?

时间:2014-11-24 15:27:39

标签: flash actionscript-2

我正在制作将在Google广告网络上展示的横幅广告。但是,Google不接受在代码中使用math.random的广告。

我发现很少的代码,但它不起作用。我找到的最相关的是这个,但仍然不适合我 http://wondergiant.com/2013/03/random-without-math-random/

有谁可以帮我解决这个问题,它如何在AS2上运行?

这是原始引用:

    var pressed = false;

    var go = function() {

    width = 300;
    height = 200;
    max_snowsize = 20;
    snowflakes = 15;


for (i=0; i<snowflakes; i++) {

    t = attachMovie("snow", "snow"+i, i);
    t._alpha = 40+Math.random()*60;
    t._x = -(width/2)+Math.random()*(1.5*width);
    t._y = -(height/2)+Math.random()*(1.5*height);
    t._xscale = t._yscale=50+Math.random()*(max_snowsize*10);
    t.k = 1+Math.random()*2;
    t.wind = -1.5+Math.random()*(1.4*3);
    t.onEnterFrame = mover;
}
    };


    mover = function() {
this._y += this.k;
this._x += this.wind;
if (this._y>height+10) {
    this._y = -20;
}
if (this._x>width+20) {
    this._x = -(width/2)+Math.random()*(1.5*width);
    this._y = -20;
} else if (this._x<-20) {
    this._x = -(width/2)+Math.random()*(1.5*width);
    this._y = -20;
}

if(pressed){
    this._alpha -= 1;
}
    }

    // start snow

    go();        

1 个答案:

答案 0 :(得分:0)

如果您可以找到在该横幅中获取当前时间的方法,请使用该时间值作为种子来运行自定义算法。只有当你得到随机种子时才能生成随机,甚至可能是你可以获得的任何信息,页面浏览量,在线用户,系统处理器使用情况,(所有这些访问都受到限制我相信。有理由横幅使用as2 not as3)但是你可能会发现一些漏洞:)

  1. sys
  2. ouh有一种方法来捕获用户滚轮的使用情况 - 我相信这是一个好种子,或者至少鼠标悬停事件可能是岸上的种子。