Frame 1 – Main screen
The Soft Keys component (softKeys_sks instance) is always visible and is responsible for switching views, for playing or pausing a song, for selecting a new song or exit the application.
There are three Soft Keys: left (LSK), middle (MSK) and right soft key (RSK). Their labels can be customised either using the Parameters panel (Window > Properties > Parameters) or using code.
The instance placed on stage already has its labels customised via the Parameters panel with the following values:
|LSK content (text or path)||"Playlist"|
|MSK content (text or path)||"Play"|
|RSK content (text or path)||"Back"|
The Soft Keys labels vary when the playlist view is loaded or when the song state (playing or paused) changes. This modification during runtime is possible using ActionScript code.
The code below shows the customisation of MSK when the song starts to play:
The following table shows all the values that each soft key can assume in the application:
|LSK label||MSK label||RSK label|
|mcPlayer view is loaded||"Playlist"||"Play"||"Back"|
|A song starts to play with mcPlayer view loaded||"Playlist"||"Pause"||"Back"|
|A song is paused with mcPlayer view loaded||"Playlist"||"Play"||"Back"|
|mcPlaylist view is loaded||""||"Play"||"Back"|
The Soft Keys component dispatches two events when any soft key is selected: onSoftKeyDown (when a Soft Key is pressed) and onSoftKeyUp (when a Soft Key is released). This application uses the onSoftKeyDown event with the following structure to respond to user interaction:
The function of each soft key may vary according to the selected view, since the views can redefine the Soft Keys onSoftKeyDown event handler.
The openScreen method allows the user to switch between views. The following code is implemented on the left soft key of main frame 1:
If the application does not have songs to play, LSK and MSK are disabled to avoid unauthorised interactions:
softkeys_sks._isLSKEnabled = false;
softkeys_sks._isMSKEnabled = false;
The Text component (txtTitle_txt, txtAuthor_txt, txtAlbum_txt, txtPlaybackTime_txt instances) is used on mcPlayer view to provide information about the current song. If there is no file to open, it is used to display a warning message.
txtTitle_txt._text = mediaTitle;
txtAuthor_txt._text = mediaAuthor;
txtAlbum_txt._text = mediaAlbum;
txtPlaybackTime_txt._text = formatTime(mediaPlaybackTime);
The Progress Indicator component (progressTime_pgi instance) is placed inside the mcPlayer view (for more information, see “mcPlayer Frame 1 – Player definitions” on page 13. If the view is loaded or reloaded, the current progress of the song must be set, otherwise the component may not work:
And also the Progress indicator maximum value should be set:
mcContainer_mc.mcScreen_mc.progressTime_pgi._maximum = mediaDuration;