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

  • Home
  • SEARCH
  • 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 4553322
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 21, 20262026-05-21T16:55:45+00:00 2026-05-21T16:55:45+00:00

Hello Im creating a game , that have more than 200 sounds , so

  • 0

Hello Im creating a game , that have more than 200 sounds , so I cannot just put the sounds in my libray in flash and then instanciate them as class and play them. Because the sound it will play when I click one object is not always the same.

I have this function to play background sound , where enters the name of the song I wanna to be played :

public function startMusicBack(music:String):void{

        var musicback:Sound = new Sound();
        var bgChannel:SoundChannel;
        var bgTransform:SoundTransform = new SoundTransform(1); 

        var req:URLRequest = new URLRequest(music); 



        try {

            musicback.load(req);

            //parar todos os sons
            SoundMixer.stopAll();
            // vou transformar o som para ele ficar mais baixo
            bgTransform.volume = .05;
            //faço o play do som mas meto num soun
            bgChannel= musicback.play(0,999,bgTransform);
        }
        catch (err:Error) {
            trace(err.message);
        }

}

Ok this worked fine until I tryied do a export of the swf file , and then I got messages of error because of the path to the music is not correct .

Ok my question is , how can I embed the past with the sounds in the swf or how can I call musics in library of flash in runtime ???

  • 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-21T16:55:46+00:00Added an answer on May 21, 2026 at 4:55 pm

    You can embed sounds directly into your SWF using the Embed tag:

    // the path here is relative to the *File*, not the SWF
    [Embed(source = "../../../../../assets/someSound.mp3", mimeType = "audio/mpeg")]
    public var mySound:Class;
    

    then you can create a new Sound as:

    var s:Sound = new mySound;
    

    Although, with 200 sounds, this’ll probably make your SWF enormous and make your compile time a pain in the ass. For the problem that you’re having, it just looks like the path to your music file is wrong. If you had a project layout like this:

    parentFolder
        - assets
            - mySound.mp3
        - bin
            - output.swf
        - src
            - subFolder
                - Main.as
    

    Then in your main class, you pass the path to the sound as relative to your *SWF* file (i.e. output.swf), so call your function like:

    this.startMusicBack( "../mySound.mp3" );
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Hello I have the following error by git-fsck, which cannot be cleaned by git-gc
So I have been working on a 2 player Tic-Tac-Toe game in java that
Hello I am creating a Windows application (WPF) that is going to be running
Hello I am creating a windows application that will be installed in 10 computers
Hello I am creating a CMS and some of the functionality of it that
Possible Duplicate: Creating or assigning variables from a dictionary in Python Hello we have
Hello can anybody solve this please I'm creating the object in the action class
Hello I am working with a simulator that uses rcS scripts to boot, this
Hello we have an SQL server application running over a low bandwith connection. We
Original Question: Hello, I am creating very simple hobby project - browser based multiplayer

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.