A Flash Developer Resource Site

Results 1 to 6 of 6

Thread: External SWF not playing sound

  1. #1
    Junior Member
    Join Date
    Dec 2006
    Posts
    3

    External SWF not playing sound

    Hopefully this is the right board for this question. I'm trying to load an external swf (we'll call it 'G') into another swf (which I'll call 'T'). If I run 'G' by itself, all of the sounds play without a problem. However, when I run it from within T, none of the sounds play. I've poked around with google, and I can't seem to find any advice that fixes the problem. Here's a little code to make things more clear:

    [All of this is Actionscript 2.0 and it's being written in Flash 8.]

    The code that loads the sound in G:

    planeSound = new Sound(_parent.windSound_mc);
    planeSound.attachSound("planeSound");
    planeSound.setVolume(100);
    planeSound.stop("planeSound");

    (_parent here is the same as _root. I just didn't want to attach to _root because I knew _root would change when I loaded it into T.)

    The code that loads G into T:

    loadMovie("gasGame.swf", "_root.mov_screen4.gasGameClip");

    And finally, some sounds that are loaded in T, just so you can see if maybe the fact that I stop those before starting the external swf is causing some sort of issue:

    _root.bgMusic = new Sound(_root.musicMC);
    _root.bgMusic.attachSound("musicSound");
    _root.bgMusic.setVolume(90);
    _root.bgMusic.stop("musicSound");

    (None of the variable names for sounds in G are the same as those in T. I doublechecked that to make sure.)

    Any help is greatly appreciated. Let me know if you need any more info / want to see more code snippets.

    Thanks again,
    -d

  2. #2
    Senior Member
    Join Date
    Jan 2006
    Posts
    140
    if you can post your fla i will look at it for you

  3. #3
    Senior Member
    Join Date
    Sep 2001
    Location
    Manhattan
    Posts
    398
    Quote Originally Posted by NotBillCosby

    The code that loads the sound in G:

    planeSound = new Sound(_parent.windSound_mc);
    planeSound.attachSound("planeSound");
    planeSound.setVolume(100);
    planeSound.stop("planeSound");

    (_parent here is the same as _root. I just didn't want to attach to _root because I knew _root would change when I loaded it into T.)
    If _parent in "planeSound = new Sound(_parent.windSound_mc);" is the _root then that is where your problem lies. When Movie G is played by itself then it sees _parent as it's own _root thus it allows the attachSound because it is from it's own library. The second you load G into T then you are trying to attach a sound from G's library into the _parent which is actually the _root of T. Flash will not allow you to attach anything from another swfs library.

    This is my best guess without all of your code in front of me but it sounds like the problem. Good Luck.
    JA

  4. #4
    Junior Member
    Join Date
    Dec 2006
    Posts
    3
    Thanks for the help. I tried attaching the sounds in G to movieclips just called planeSound_mc, ringSound_mc, and explosionSound_mc, (no references to _parent this time) but haven't had any luck with that either. Is it possible that it is actually bringing the sounds in correctly when i load G but the volume is so low that I wouldn't be able to hear them? Is there anyway I can check to see if those sounds have been loaded?

    Thanks again for your help,
    -d

  5. #5
    Junior Member
    Join Date
    Dec 2006
    Posts
    3
    Quote Originally Posted by JHarlequin
    If _parent in "planeSound = new Sound(_parent.windSound_mc);" is the _root then that is where your problem lies. When Movie G is played by itself then it sees _parent as it's own _root thus it allows the attachSound because it is from it's own library. The second you load G into T then you are trying to attach a sound from G's library into the _parent which is actually the _root of T. Flash will not allow you to attach anything from another swfs library.

    This is my best guess without all of your code in front of me but it sounds like the problem. Good Luck.
    JHarlequin,
    You were right. Importing the sounds into T's library using the same linkage that I was using in G fixed the problem. Thanks again for your help.

    -d

  6. #6
    Senior Member
    Join Date
    Sep 2001
    Location
    Manhattan
    Posts
    398
    Sweet! Glad it worked out.
    JA

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