The For loop runs through all positions of the array from 0 to 4. The value of the current array variable is not translated into the variable. The If condition checks the possible match of an array position with the current in number.
If it is included, the movie clip jumps to frame 4 and also issues a message. If the number is not included, the clip will continue normally into the next frame. Here in Frame 3, the playback process for the music is started and the skip clip is reset.
In frame 4, we calculate the new order number according to the known pattern. Then restart the query in Frame 2 to see if the new number is forbidden.
Bring the completed clip with the instance name skip to the stage.
Of course, this query must also be triggered when a track is played to the end. This makes a detour into the loader clip and changes the function in the last frame as follows
Finally, return to Scene 1 and create a second frame. Here you can tell the user that all tracks have been played. If you want to provide a reset button, simply send it back to Frame 1, as all important variables are initialized there. Important: The loader clip, the skip-clip and the control clip may no longer appear in frame 2, so that they can be restarted during the reset.
So far, we've set up five songs, which are in a folder named Music. This is, of course, an unnecessary limitation if you want to offer even more music. If your interface offers space for this, you can provide the user with a set of genre buttons to control different folders.
The ultimate trigger for the folder change is in the loader-clip. Here, we had fixed in the first frame that the folder is set as text. This substitution is replaced by a variable. From the wording
Is now
For the principle to function from the beginning, there must be an initialization in the first frame of scene 1. Since a change of the genre is equivalent to a reset, we help here with a trick: We write a unique start variable. If this is true, the folder name is not reinitialized on reset
As you can see, the Top Ten (lines 3 and 4) startup selection is also included in this initialization.
We have inserted here three genre buttons with the instance names pop_clip (default), soul_clip and klassik_clip. They are the same as the two clips for random and topten. There are, therefore, movie clips with invisible buttons and texts that change color when a button is clicked.
This invisible button has the following programming
Each button changes the folder variable and also returns the other two buttons to the original state. The two other clip buttons are also programmed in the same way. In addition, you must also insert the Reset command into the buttons for Top Ten and Random, so simply insert _root.gotoAndPlay (3) at the end of the button script.
The reference to frame 3 of the main movie triggers the reset, because there is only a simple image programming: gotoAndPlay (1), Attention: The layer with the genre buttons and the random or top ten must still be present in this third frame , So that the selected button retains its color and no optical reset occurs.
No comments:
Post a Comment