You can create a counting integer variable that adds every time it enters the snowflake function and a goal variable to tell the function at which frame number to initiate the code in the function, like this:
Code:
stage.addEventListener(Event.ENTER_FRAME, snowflake);
//init variables
var count:int=0;
var goal:int=int(Math.random()*50+50);//this will give you a number from 50-100
function snowflake(event:Event):void{
if(count>=goal){
count=0;
goal=int(Math.random()*50+50);
//add your code that was initially in your function here
}
}
I believe this would work, there may be an error in the code, have not checked it.
stage.addEventListener(Event.ENTER_FRAME, snowflake);
//init variables
var count:int=0;
var goal:int=int(Math.random()*50+50);
//this will give you a number from 50-100
var _Snowflake:mcSnowflake; //I PUT THIS IN HERE
function snowflake(event:Event):void{
if(count>=goal){
count=0;
goal=int(Math.random()*50+50);
//add your code that was initially in your function here
I am making a game for college and have been trying to get this right for ages.
"snowflake" is actually a coin! I recycled actionscript from another project, so left the name "snowflake" on the coin movie.
Basically the coins, fall from the sky at random and a little character at the bottom moves left and right and tries to catch them. I intend to use a hit test and dynamic text to count the coins he catches and then he flies off to piggy heaven
Sounds easy enough, but have been at it for days now!!
I attached two fla,
in piggy2.fla , i got piggy moving
in the 'lots of coins.fla', I have coins falling every frame instead of every now and then as you would expect in a game