Ask a Question related to Adobe Flash, Flex & Director, Design and Development.
-
Glen Gummess webforumsuser@macromedia.com #1
Using Math.random to go to random frames
Hello everyone. My cerebral density is preventing me from seeing the solution to this problem.
I have the following code which causes the user to jump to various frames in a timeline at random; the user clicks a component-button that actuates the addOn function below:
generateNew = function () {
n = Math.round(Math.random()*10);
};
addOn = function () {
generateNew();
gotoAndStop(n);
if (_currentFrame == n){
trace("the current frame is " + _currentFrame);
}
}
stop();
However, I don't want the user to go to the same frame twice during the session (before the page is reloaded). Can you suggest how I may prevent the same frame from recurring?
Many thanks,
Glen Gummess
Instructional Designer
University of St. Francis.
Joliet, IL
Glen Gummess webforumsuser@macromedia.com Guest
-
AIX testers wanted for Math::Random
I recently received a bug report for Math::Random versions 0.67 and 0.68. The environment was AIX 5.2.0.0, perl 5.8.7 (or 5.8.8?), and gcc 4.0.1. I... -
Math-Random-MT-Auto-4.08.00.tar.gz
As in previous versions, make test show a lot of NOK maybe because I use a 64 bit int compiled perl. Does anyone could correct this? TIA, --... -
math.random.whats wrong with my code?!!
Why is it doing this?? What I want is for my mc to slide to a new random x position when it is less than 5 pixels away from its target, it keeps... -
Math random help
Hi, My name is John. I have a MC 600 X 150. I want the clip to scroll continuously from right to left, while changing the y position randomly... -
Math::GMP tests and Crypt::Random fail on Compaq (Math::Pari related ??)
Hi, I've been compiling Math::GMP for different OS's in order to use Net::SFTP and I have successfully compiled and used it for Solaris,... -
elemental .std webforumsuser@macromedia.com #2
Re: Using Math.random to go to random frames
just when random function generate a frame number save it to a variable and when you call again the random function compare it with this variable if they are equal call again random function compare again and again until the new number which is produced is different.
your script will look likes:
totalFrames=20;
frames = new Array(totalFrames);
newFrame = function () {
_root.frameN = random(totalFrames-1);
};
function check() {
for (i=1;i<=totalFrames;i++) {
if (frames == 'visited') {
_root.check = false;
} else {
frames = 'visited';
_root.check=true;
}
}
}
addOn = function () {
//i am not sure for the syntax of this loop
while (_root.check != true) {
newFrame;
}
gotoAndStop(_root.frameN+1);
}
addOn;
stop();
Do you agee ?
elemental .std webforumsuser@macromedia.com Guest
-
Glen Gummess webforumsuser@macromedia.com #3
Re: Using Math.random to go to random frames
I'll give it a try.
Thank you!
Glen
Glen Gummess webforumsuser@macromedia.com Guest



Reply With Quote

