dcsimg
A Flash Developer Resource Site

Results 1 to 2 of 2

Thread: 3 songs ONE movieclip?

  1. #1
    Member
    Join Date
    Dec 2000
    Location
    Mesa, Az
    Posts
    86
    I have a cd player type thing setup for my website. The users can select between 3 songs, and control with play, stop, pause, next song, previous song.
    Anyway, I have spent several hours trying to make this work, but no luck.

    I am using the following code to call up the music clips:

    var volPercent = 25;
    volumeText = volPercent + "%";
    volumeFill._xscale = 25;

    AD = new Sound();
    AD.attachSound("AD");
    AD.setVolume(volPercent * 2);

    WWYT = new Sound();
    WWYT.attachSound("WWYT");
    WWYT.setVolume(volPercent * 2);

    SIL = new Sound();
    SIL.attachSound("SIL");
    SIL.setVolume(volPercent * 2);

    Is that incorrect?
    I am doing linkage [exporting in the first frame].
    If i am doing anything wrong could somebody help me out.
    If there is no problem with the above, it is probably within the play button.

    The buttons which are used to keep track of which track the user is on basically add or subtract 1 to track [if the track isn't already at 1 or 3.] (track=track+1).

    Here is the code for the play button: (notice the if statements are centered around the "track.")

    ----------------------

    on (release){
    if (track = 1){
    AD.stop();
    WWYT.stop();
    SIL.stop();
    i=1;
    function timeme (){
    now = new Date();
    var hours = now.getHours();
    var minutes = now.getMinutes();
    var seconds = now.getSeconds();
    _root["nowtime"+i] = (Number(hours)*3600)+(Number(minutes)*60)+seconds;
    _root.newstarttime = _root["nowtime"+i] - _root.nowtime1;
    i++;
    }
    AD.start(_root.newstarttime, 10000);
    timeme();
    }

    else if (track = 2){
    AD.stop();
    WWYT.stop();
    SIL.stop();
    i=1;
    function timeme (){
    now = new Date();
    var hours = now.getHours();
    var minutes = now.getMinutes();
    var seconds = now.getSeconds();
    _root["nowtime"+i] = (Number(hours)*3600)+(Number(minutes)*60)+seconds;
    _root.newstarttime = _root["nowtime"+i] - _root.nowtime1;
    i++;
    }
    WWYT.start(_root.newstarttime, 10000);
    timeme();
    }

    else if (track = 3){
    AD.stop();
    WWYT.stop();
    SIL.stop();
    i=1;
    function timeme (){
    now = new Date();
    var hours = now.getHours();
    var minutes = now.getMinutes();
    var seconds = now.getSeconds();
    _root["nowtime"+i] = (Number(hours)*3600)+(Number(minutes)*60)+seconds;
    _root.newstarttime = _root["nowtime"+i] - _root.nowtime1;
    i++;
    }
    SIL.start(_root.newstarttime, 10000);
    timeme();
    }
    }




    ----------------------

    the date function is so they can pause and unpause...
    if anyone sees anything that could help, please tell me.
    If you wouldn't mind helping me out with the project, that would be awesome too.

    AIM: SecondClassCtzn
    MSNIM: stokertodd@hotmail.com
    email: stokertodd@hotmail.com

  2. #2
    Moderator
    Join Date
    Apr 2001
    Location
    Akron OH, USA
    Posts
    4,841
    1) be sure to associate your sound objects with a unique mc.

    use:
    AD = new Sound(target path to unique mc);

    instead of:
    AD = new Sound();

    do this for all sound objects.

    2) you are duplicating a bunch of code in your if then statements. Assuming you want to only play one sound at a time, it would seem simpler to just have one sound object as a container in which you attach new sounds.

    for example you could create one sound object called cdplayer.

    cdplayer = new Sound(target path to unique mc);

    your song selection menu calls attachSound("linkageID") to connect a sound to the sound object.

    _root.cdplayer.attachSound("linkageID");

    play button just plays from start time. Create a function outside of the button to return the new start time.

    on(release){
    cdplayer.stop(); // avoid doubling
    cdplayer.start(timeme());
    }

    using the getTimer() action in timeme() is probably much simpler than using the date function to keep track of time.

    I have an online code example to demonstrate but the server is not responding at the moment.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  




Click Here to Expand Forum to Full Width

HTML5 Development Center