AudioPlayerMenu

Kind of class: public class
Package:
Inherits from:
  • Sprite
Version: 13 Jul 2010 Added selectPlayer method
, 7 Mar 2010
Author: John Polacek, john@johnpolacek.com
Classpath: com.johnpolacek.media.AudioPlayerMenu
File last modified: Friday, 18 February 2011, 00:30:48
A vertically stacked grouping of AudioPlayers
Example
  • import com.johnpolacek.media.AudioPlayer;
    import com.johnpolacek.media.AudioPlayerMenu;
    var urls:Array = ["song1.mpg","song2.mp3","song3.mp3"];
    var players:Array = [];
    var songsLoaded:int = 0;
    for (var i:int = 0; i < urls.length; i++)
    {
    var player:AudioPlayer = new AudioPlayer();
    players.push(player);
    player.load(urls[i], false);
    player.addEventListener(Event.COMPLETE, onAudioLoadComplete);
    }
    function onAudioLoadComplete(event:Event):void
    {
    songsLoaded++;
    if (songsLoaded == players.length)
    {
        var menu:AudioPlayerMenu = new AudioPlayerMenu();
        for (var i:int = 0; i < players.length; i++) { menu.addPlayer(players[i]); }
        addChild(menu);
    }
    }
    

Summary

Constructor
Instance properties
  • players : Array
    • Array of players loaded into the menu.
Instance methods

Constructor

AudioPlayerMenu

function AudioPlayerMenu(...audioPlayers)
Parameters
audioPlayers:AudioPlayers that are added to the AudioPlayerMenu

Instance properties

players

players:Array = [](read,write)

Array of players loaded into the menu.

Instance methods

addPlayer

function addPlayer(player:AudioPlayer) : void
Parameters
player:AudioPlayer to add to the AudioPlayerMenu

destroy

function destroy() : void

selectPlayer

function selectPlayer(playerIndex:int) : void
Parameters
playerIndex:Index of player to select and play.