NTNUJAVA Virtual Physics Laboratory
Enjoy the fun of physics with simulations!
Backup site http://enjoy.phy.ntnu.edu.tw/ntnujava/

Easy Java Simulations (2001- ) => Questions related to EJS => Topic started by: lookang on January 20, 2009, 09:33:14 am



Title: how to make a slider remember previous value after reset simulation.
Post by: lookang on January 20, 2009, 09:33:14 am
how to make a slider remember previous value after reset simulation but yet also start off the first time only as a value say minimum of the slider?

I managed a way to get simulation to remember previous value after reset of simulation by leaving the initial value of the slider to be BLANK!

but i need to drag the slider for the value 1 to be registered into the slider variable mass1s which is  mass 1 stored, which i hope that a way to overcome the need to drag the slider for usability purposes.

is there is better solution to start with slider variable minimum but subsequently remember the stored values later?

i scan at some of your xml but i think i can't find an example that does this:)

thanks!


Title: Re: how to make a slider remember previous value after reset simulation.
Post by: Fu-Kwun Hwang on January 20, 2009, 01:26:25 pm
Reset will reset  everything from the beginning (Nothing to be remembered!).
You should use _initialize() instead of _reset() 
to restart the simulation with different user setting.
(You need to and add code to initialize page to initial values)

For examples:
There is a slider to set vi, add _initialize() for drag action
Add the following code to initialize page
Code:
t=0;
x=xmin+size;
vx=vi; // vx will be set to user selected value
You can also have a slider to set vx.
Then, the code in the initialize page might be something like:
Code:
t=0;
x=xmin+size;


Title: Re: how to make a slider remember previous value after reset simulation.
Post by: lookang on January 20, 2009, 01:37:25 pm
Reset will reset  everything from the beginning (Nothing to be remembered!).
You should use _initialize() instead of _reset() 
to restart the simulation with different user setting.
(You need to and add code to initialize page to initial values)

Oic..... i need to use _initialize() more often.


For examples:
There is a slider to set vi, add _initialize() for drag action
Add the following code to initialize page
Code:
t=0;
x=xmin+size;
vx=vi; // vx will be set to user selected value
You can also have a slider to set vx.
Then, the code in the initialize page might be something like:
Code:
t=0;
x=xmin+size;

I think am already tinkering with stored values in the initialization page so should be ok now! thanks