This content has been marked as final. Show 9 replies
each time your flash plays, it can generate however many random numbers you need to start, stop or otherwise make your display of this experiment be (roughly) unique for each visitor.
when you say "however many random numbers", do you mean random numbers within a range (ie the animation will only stop somewhere between frames 20 to 80, if the animation was 100 frames long in total)?
so how would one go about setting this up?
So you would have:
- a flask of disolved vitamin c solution
- simulated pour of iodine solution from a tube
- the flask filling
- the tube emptying
- a change of color in the flask
I think I'm good so far, but the whole random frame on each viewing is fuzzy. So here it goes...
If you create the animation one long _root timeline you could have code in frame 1 that picks a random frame and plays from there:
var numberOfFrames:Number = 45; // the length of your animation in frames
var rnd:Number = Math.floor(Math.random() * numberOfFrames); // picks a random number between 0 and 45
Now for the changing of color. Make the liquid in the flask tween from a gray tint to a red tint - instead of using two clips you only need tween the one.
Let me know if you need any additional help.
If you need to use a range between 20 and 80, modify the code as such:
var startRange:Number = 20;
var endRange:Number = 80;
var rnd:Number = Math.floor(Math.random() * (endRange - startRange + 1)) + startRange; // picks a random number between 20 and 80
you're pretty close See4th except the animation needs to play from the begining and stop at a random frame (before frame 45 from your example)
it's only then at that stopped frame, that the flask changes colour (basically the iodine won't change the colour of the vitamin c until it's molecules out number the vitamin c's, gee i didn't expect to be teaching a science lesson here :) especially since im no way at all a scientist)
You're the man Jeff!!!
I've looked at what you've done and it seems to make sense.
Is there anyway I could also have a random number appear under the flask that displays what the mass of the flask liquid is. It would need to be a random mass number within a range, say inbetween 10-50gms (to 2 decimal points)
Because in the end the students will need to have the mass divided by the volume of liquid used to get the vitamin c change colour
and will the student be able to type in the answer to this equation with the answer being in a certain range?
thx once again
I'll help you with the mechanics, but it's important that wrap your head around this.
We are currently generating a random number between 0 and 70. To make things easier on you we'll change our random number process slightly so that you don't have to work with 0 if it ever did hit. (see code below)
Now you will create number called amtDispensed and derive a formula that will always generate a number between 10 and 50 based on a random number of 1 to 70.
Add a dynamic text field to the bottom of the stage and give it an instance name of 'amt_txt'.
Then in your checkFrame function, add your formula that generates amtDispensed (your 10 to 50 number).
Then add a line that says amt_txt.text = amtDispensed;
Let's get that much going. Post your code. When we tackle this, we'll move on to rounding the number to 2 decimals.
Sorry I'm wondering why the random number range of 10-50 needs to be based off the 1-70?
Basically the student will be given a mass of the vitamin c on screen (in our random range of 10-50) and write that down on a notepad, then they'll start the animation and find the difference in volume lost from the tube, ie take the reading before adding the iodine, then a reading after, at the end of the animation and then comparing the difference. So the mass of the vitamin c doesnt have any relationship with volume lost from the tube. I hope that makes sense.
I've found some code that will generate a random number, but not to a certain decimal point, see below:
return Math.floor(Math.random() * 2);
// create a master array
//populate it with the full set of numbers you want to use
// create an array of results
// grab the number from the shuffled array
//and add it to the results array
is this ok or is there something better?