Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 3595394
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 18, 20262026-05-18T19:50:46+00:00 2026-05-18T19:50:46+00:00

On one frame in my flash project there are 6 buttons. When you click

  • 0

On one frame in my flash project there are 6 buttons. When you click a button a different song plays. Simple. The problem is, the first song in the list is playing the second the project loads instead of waiting for someone to click the button!

import fl.events.SliderEvent;
var snd:Sound;
var channel:SoundChannel;
var trans:SoundTransform;
var currSong:String;
var currVol:Number = .5;
var currPan:Number = 0;


var songList:Array=new Array("Drifting.mp3","Push.mp3",
                             "Stupid.mp3","Train Wreck.mp3","World on Fire.mp3","Fallen.mp3");


panSlide.visible=false;
volSlide.visible=false;


song1.addEventListener(MouseEvent.CLICK, chooseSong);
song2.addEventListener(MouseEvent.CLICK, chooseSong);
song3.addEventListener(MouseEvent.CLICK, chooseSong);
song4.addEventListener(MouseEvent.CLICK, chooseSong);
song5.addEventListener(MouseEvent.CLICK, chooseSong);
song6.addEventListener(MouseEvent.CLICK, chooseSong);
panSlide.addEventListener(SliderEvent.CHANGE, panChange);
volSlide.addEventListener(SliderEvent.CHANGE, volumeChange);



function chooseSong(e:MouseEvent):void {
    switch (e.currentTarget.name) {
        case "song1":
            currSong = "../MP3s/"+songList[0] as String;
            break;

        case "song2":
            currSong = "../MP3s/"+songList[1] as String;
            break;

        case "song3":
            currSong = "../MP3s/"+songList[2] as String;
            break;

        case "song4":
            currSong = "../MP3s/"+songList[3] as String;
            break;

        case "song5":
            currSong = "../MP3s/"+songList[4] as String;
            break;

        case "song6":
            currSong = "../MP3s/"+songList[5] as String;
            break;
    }
    if (snd != null) {
        channel.stop();
    }
    snd = new Sound();
    snd.load(new URLRequest(currSong));

    channel = new SoundChannel  ;
    trans = new SoundTransform(currVol,currPan);
    channel = snd.play();
    channel.soundTransform = trans;
    panSlide.visible = true;
    volSlide.visible = true;
}


function volumeChange(e:SliderEvent):void {
    currVol = e.target.value;
    trans.volume = currVol;
    channel.soundTransform = trans;
}



function panChange(e:SliderEvent):void {
    currPan = e.target.value;
    trans.pan = e.target.value;
    channel.soundTransform = trans;
}
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-18T19:50:46+00:00Added an answer on May 18, 2026 at 7:50 pm

    Are you sure you haven´t accidentally added a sound to the timeline? If not you should add a trace inside the method chooseSong and check if it is triggered when you load the project.

    I created a new file with a mc (song1) on stage and this script. Does this work for you?

    song1.addEventListener(MouseEvent.CLICK, chooseSong);
    
    function chooseSong(e:MouseEvent):void {
        trace (e.currentTarget.name)
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

There was a beautiful way to organize class property in frame of one function,
I'm building a flash application and on one frame I have a number of
In frame 1 of a very simple flash file, I have the following code:
Greeting, I have problem stopping FLVPlaypack component when I navigate from one frame to
I have a flash CS project. I have one stage and some frames. How
I am doing a simple Flash button that controls the playing of a moving
Image.FromFile(@path\filename.tif) or Image.FromStream(memoryStream) both produce image objects with only one frame even though the
We have some web pages which have two frames, with one frame in the
I am examining a core dump, and noticed that in one frame the 'this'
I have a data frame where one particular column has a set of specific

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.