-
Replacing math.random with a function?
Basically, I am trying to make a Banner ad that will go on Google's ad network. However it turns out, they don't accept ads that use math.random in the code.
So I am trying to convert my code from using math.random to call a function that simulates the same thing. I found this information on the topic, but am stuck.
http://wondergiant.com/2013/03/random-without-math-random/
After this inserting this code and finding and replacing math.random() with getRan(20), I get no errors in my code, but the randomly generated snowflakes that I had working, no longer work. Obviously I am implementing this wrong. Can anyone tell me how I could get this to work?
Here is the original code.
Code:
function createSnow(i:int):void {
var m:MovieClip = new snowflake();
m.mouseEnabled = false;
if(intro == true) {
m.y = Math.random() * - margin *2;
m.x = Math.random() * (sw / 2 + margin) - margin * 2;
} else {
m.y = Math.random() * (sh + margin*2) - margin*2;
m.x = Math.random() * (sw + margin*2) - margin*2;
}
m.rotation = Math.random() * 360;
m.depth = Math.random() * (snowZmax*2-snowZmin) + snowZmin
m.depth = int(m.depth*100)/100
m.scaleX = m.scaleY = Math.max(0.4, (1/(Math.max(0, m.depth))-0.5)*snowSize)
//trace("d : "+m.depth + " = scaleX " + m.scaleX)
if(fade == true) {
m.alpha = 0;
} else {
m.alpha = newAlpha(m);
}
addChild(m);
snowX(m);
snowY(m);
}
If I replace all the "math.round" instances with "getRan(20)", I don't get any snowflakes, but I also do not get any errors. Any advise on how to possibly get this to work would be great!
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|