mySequentialCollection __________|____________ | | | MusicJob MusicJob MusicJobFirst we'll define a SequentialCollection, and use the add() method to fill it with three MusicJobs. The essential code fragments are below:
SequentialCollection mySequentialCollection; ... mySequentialCollection = new SequentialCollection(); mj1 = new MusicJob(); mj2 = new MusicJob(); mj3 = new MusicJob(); ... mySequentialCollection.add(mj1); mySequentialCollection.add(mj2); mySequentialCollection.add(mj3); ...An applet with this hierarchy is running directly below.
Notice that each MusicJob repeats a different number of times (the first twice, the second three times, and the third four times). That is MusicJob's repeatCount and is set with the MusicJob's setRepeats() method.
Note also that each one runs at a different rate. That is determined with MusicJob's setRepeatPause() method, measured in seconds.
Finally, notice that the entire SequentialCollection repeats twice. That is set by calling mySequentialCollection.setRepeats(2).
Here is the complete source code for this applet.
Next we will have the collection randomly choose which child to launch
every time it repeats. This is called acting "behaviorally".
Previous | Tutorial Index | Tutorial Contents | Next |
(C) 1997 Phil Burk and Nick Didkovsky, All Rights Reserved JMSL is based upon HMSL (C) Phil Burk, Larry Polansky and David Rosenboom.