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 -
_global.my_beep_sound = new Sound();
-
my_beep_sound.attachSound("beep_sound");
-
trace("Sound file loaded"+my_beep_sound);
-
player.swf -
-
// create an empty movie clip
-
this.createEmptyMovieClip("my_mc", this.getNextHighestDepth());
-
-
// Create Movie clip loader for sound
-
var my_mcl:MovieClipLoader = new MovieClipLoader();
-
var mclListener:Object = new Object();
-
-
// Setup events for preloader
-
mclListener.onLoadStart = function(target_mc:MovieClip):Void {
-
};
-
mclListener.onLoadProgress = function(target_mc:MovieClip, numBytesLoaded:Number, numBytesTotal:Number):Void {
-
};
-
mclListener.onLoadComplete = function(target_mc:MovieClip):Void {
-
};
-
mclListener.onLoadInit = function(target_mc:MovieClip):Void {
-
trace("init");
-
trace(my_beep_sound);
-
my_beep_sound.start(0,999);
-
};
-
my_mcl.addListener(mclListener);
-
-
// Load sound
-
my_mcl.loadClip("sound.swf",my_mc);
-
The trace output is: -
Sound file loaded: [object Object]
-
init
-
[object Object]
-
Thanks,
Chromis
8 2820
When you create your new sound object, try doing:
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
No that doesn't work. Here's a discussion on the problem that seems to explain it pretty well (and offers a solution too).
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?
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.
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.
@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.
Haha fair play, I'll remember that in the future.
Chromis
Sign in to post your reply or Sign up for a free account.
Similar topics
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.
...
|
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...
|
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...
|
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.
...
|
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...
|
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...
|
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...
|
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...
|
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...
|
by: Charles Arthur |
last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
|
by: emmanuelkatto |
last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud.
Please let me know.
Thanks!
Emmanuel
|
by: nemocccc |
last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
|
by: Hystou |
last post by:
There are some requirements for setting up RAID:
1. The motherboard and BIOS support RAID configuration.
2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
|
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,...
|
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...
|
by: Oralloy |
last post by:
Hello folks,
I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>".
The problem is that using the GNU compilers,...
|
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...
|
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,...
| |