Copy link to clipboard
Copied
So I try to make my program go to a random slide.
So I put this code
{gotoAndPlay(155+function fl_GenerateRandomNumber_2(limit:Number):Number
{
var randomNumber:Number = Math.floor(Math.random()*(limit+1));
return randomNumber;
}
trace(fl_GenerateRandomNumber_2(4));)}
In this case, I want the program to go to the frame from 155-159 (randomly)
The error is
-expecting rightparen before trace
-expecting rightbrace before rightparen
Question #1
1) Ok. I realieze my mistake, It got to be those brackets family. But I can't figure out which one is wrong.
2) If those 2 error edited, will this code actually works? If it is not. Is there any alternative?
Thanks
use:
gotoAndPlay(randomF(155,159));
function randomF(n1:int,n2:int):int{
return n1-1+Math.ceil(Math.random()*(n2-n1));
}
Copy link to clipboard
Copied
use:
gotoAndPlay(randomF(155,159));
function randomF(n1:int,n2:int):int{
return n1-1+Math.ceil(Math.random()*(n2-n1));
}
Find more inspiration, events, and resources on the new Adobe Community
Explore Now