473,788 Members | 2,868 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Sound doesn't play from an mc when loaded using moviecliploader

113 New Member
Hi,

I've been struggling to get sounds to work with attachSound when the sounds are stored in a swf loaded into another swf. I came across a post on a forum which supposedly explains how to to do it, however i tryed what it suggested and it doesn't work. (link)

I then tryed to use the MovieClipLoader class so that once the swf was loaded the sound would be played. What is strange though is that when the swf has loaded i can return a valid reference to the sound object, but cannot play it. This is all local, so it should play. I'm very confused.

Here is my code:
sound.swf - beep_sound.wav file is in the library with linkage identifier beep_sound
Expand|Select|Wrap|Line Numbers
  1. _global.my_beep_sound = new Sound();
  2. my_beep_sound.attachSound("beep_sound");
  3. trace("Sound file loaded"+my_beep_sound);
  4.  
player.swf
Expand|Select|Wrap|Line Numbers
  1.  
  2. // create an empty movie clip
  3. this.createEmptyMovieClip("my_mc", this.getNextHighestDepth());
  4.  
  5. // Create Movie clip loader for sound
  6. var my_mcl:MovieClipLoader = new MovieClipLoader();
  7. var mclListener:Object = new Object();
  8.  
  9. // Setup events for preloader
  10. mclListener.onLoadStart = function(target_mc:MovieClip):Void {
  11. };
  12. mclListener.onLoadProgress = function(target_mc:MovieClip, numBytesLoaded:Number, numBytesTotal:Number):Void {
  13. };
  14. mclListener.onLoadComplete = function(target_mc:MovieClip):Void {
  15. };
  16. mclListener.onLoadInit = function(target_mc:MovieClip):Void {
  17.     trace("init");
  18.     trace(my_beep_sound);
  19.         my_beep_sound.start(0,999);
  20. };        
  21. my_mcl.addListener(mclListener);
  22.  
  23. // Load sound
  24. my_mcl.loadClip("sound.swf",my_mc);
  25.  
The trace output is:
Expand|Select|Wrap|Line Numbers
  1. Sound file loaded: [object Object]
  2. init
  3. [object Object]
  4.  
Thanks,

Chromis
Mar 2 '09 #1
8 2838
Markus
6,050 Recognized Expert Expert
When you create your new sound object, try doing:

Expand|Select|Wrap|Line Numbers
  1. new Sound(this)
  2.  
Mar 2 '09 #2
chromis
113 New Member
Hi Marcus,

Can't tell you how pleased I am you've sorted that out for me, thanks! Was really stuck on that one. So does that change the timeline for the sound to the the containing mc? What is it otherwise?

Thanks again,

Chromis
Mar 2 '09 #3
Markus
6,050 Recognized Expert Expert
No that doesn't work. Here's a discussion on the problem that seems to explain it pretty well (and offers a solution too).
Mar 2 '09 #4
chromis
113 New Member
I did have a look at that whilst i was researching the issue, it's not really the way i wanted to go about it though as on the actual project that has the issue I've got a moviecliploader which loads the main swf. Your solution above worked a treat though. What's strange is I would assume the sound constructor to take the movieclip it's in as a target as default. Instead it seems to be the current root right?
Mar 2 '09 #5
Markus
6,050 Recognized Expert Expert
Oops, I hadn't seen your reply before I made my second post. Sorry about that.

Yes, I would've thought the object would default to the movie clip / button it's in - of course, your's isn't in a movie clip or button.

Time to do some research :D

Also, don't double post your question :P

Glad I could help,
Markus.
Mar 2 '09 #6
chromis
113 New Member
Sorry about the double post, although technically it's not the same question, more of a development from the previous one ;)

Thanks again for you help.
Mar 2 '09 #7
Markus
6,050 Recognized Expert Expert
@chromis
Sure, but while it's an extension of this question, it still largely relates to this thread. So, no need to create a new thread, although I won't hold it against you.

See ya around,

Markus.
Mar 2 '09 #8
chromis
113 New Member
Haha fair play, I'll remember that in the future.

Chromis
Mar 2 '09 #9

Sign in to post your reply or Sign up for a free account.

Similar topics

5
2683
by: minchu | last post by:
Hello, I want an image and sound(any format) to load and play simultaneously in my HTML or the sound should play only after the image is loaded. Is this possible?. Pls let me know how. Regards, Minchu
22
2567
by: The Road To Utopia | last post by:
Here's one for the trolls...a common jibe from them is setting up audio/video hardware under linux. Ok, true story: at work today, someone asked me if I could tell him why his XP Home would play the video from a DVD but not the audio. He had been searching for an answer for days on support.microsoft.com but found none. I suggested Google and Gateway. Gateway had nothing, but sure enough, search for *XP DVD no sound* on Google and...
1
3182
by: Marco Krechting | last post by:
Hi All, I have a database with the timer function set to warn the user that arecord is due to expire. Is there a Win API that I can use so a loud warning will go off. Not this simpel beep in access but a really, like Virus Alert kind of warning? Regards Marco
4
3482
by: Robert Gravereaux | last post by:
I'm putting together a C# .Net forms project on win2k. The application requires some sort of horn sound. I've never implemented any audio in .Net, so I'm not sure how best to accomplish this. It's an application that works with a wireless barcode scanner, in a warehouse environment. The user could be potentially 20 or 30 ft. from the PC. If the user scans something improperly, the app should sound a 'horn' to notify the user. I'm trying...
3
3297
by: illmagination | last post by:
Hi, I recently received a task to have a .wav file play only once when home page is 1st loaded and only play again when the user re-visits the page by opening a new browser. I am using asp.net 2.0 framework. Could someone please guide me? Thank you.
6
1985
by: laredotornado | last post by:
Hi, Is there a cross-browser way to play short (< 25K) sound files without spawning new windows or embedding any visual controls on the page? I would like to click a button and hear my short sound. Thanks for your help, - Dave ps - Searching Google turned up stuff for Netsacpe and IE 3, but I was hoping more for IE 7 and Firefox.
26
3905
by: Jake Barnes | last post by:
I did a search on the newsgroup comp.lang.javascript. I was searching for "how to play a sound with Javascript". I'm somewhat suprised that the majority of entries are from the 1990s, and there are almost no posts from the last 3 years: http://groups.google.com/group/comp.lang.javascript/search?group=comp.lang.javascript&q=how+to+play+a+sound+with+Javascript&qt_g=Search+this+group Even after sorting by date, there don't appear any...
8
14949
by: raylopez99 | last post by:
I have the latest version of Visual Studio 2008 Professional, which allows you to create resource files (this is the .resx file, no?), unlike the Express version, which does not. I am trying to cut and paste code that MSDN recommends for playing a simple wav file from inside an embedded file, like presumeably the 'resources' file .resx is. I want to embed the .wav file in a 'resource file' since I don't want the user storing the file on...
1
3653
anfetienne
by: anfetienne | last post by:
i have this code below that i made....it loads vars from txt file splits it then puts it into an array....once in an array it the brings the pics in from the array to create thumbnails and a larger image. my problem is i have captions to go with it and when i try to load the captions nothing happens or can be seen to be happening. i dont know where i am going wrong as i have no output or compiled errors var locVar = new Array();...
0
9656
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9498
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
1
10112
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
8993
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
7518
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6750
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5399
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
1
4070
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
3
2894
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.