-
I'm looking for a specific type of audio button
Is it possible to make a swf that plays sounds from a url? To be more clear, I mean something like
Code:
http://www.site.com/play.swf?=http://www.site.com/sounds/clip1.mp3
I have a site with a ton of sound files, and it would take forever to add them to individual swf files and put them back on their pages. I'd like the swf to just be a static image that plays the sound when clicked. (preferable with the ability to preload the sound after the click and show a small loading progress bar)
Thanks,
Jeff
-
Senior Member
All you need to do is make one movie with a variable referring to _root, something like _root.musicUrl. Then in your html page you add this var with the url:
PHP Code:
<object classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" codebase="http://fpdownload.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=8,0,0,0" width="300" height="50" id="mp3" align="middle">
<param name="movie" value="mp3.swf?musicUrl=http://www.site.com/sounds/clip1.mp3" />
<param name="quality" value="high" />
<param name="bgcolor" value="#ffffff" />
<embed src="mp3.swf?musicUrl=http://www.site.com/sounds/clip1.mp3" quality="high" bgcolor="#ffffff" width="300" height="50" name="mp3" align="middle" allowScriptAccess="sameDomain" type="application/x-shockwave-flash" pluginspage="http://www.macromedia.com/go/getflashplayer" />
</object>
- The right of the People to create Flash movies shall not be infringed. -
-
Thanks! Now I need to figure out the _root thing you are talking about
-
Senior Member
There is nothing to figure out. This is modified from the help files.
PHP Code:
this.createTextField("status_txt", this.getNextHighestDepth(), 0, 0, 100, 22);
// create a new Sound object
var my_sound:Sound = new Sound();
// if the sound loads, play it; if not, trace failure loading
my_sound.onLoad = function(success:Boolean) {
if (success) {
my_sound.start();
status_txt.text = "Sound loaded";
} else {
status_txt.text = "Sound failed";
}
};
// load the sound
my_sound.loadSound(_root.musicUrl, true);
- The right of the People to create Flash movies shall not be infringed. -
-
Ohhhh, thanks!
It plays as soon as the page loads now. I'm just gonna have to try to make it onPress, I think.
-
Senior Member
Just put that script in a button
- The right of the People to create Flash movies shall not be infringed. -
-
hmm, when I put it on a button, I get errors exporting the swf.
Code:
**Error** Scene=Scene 1, layer=Layer 1, frame=1:Line 1: Statement must appear within on handler
this.createTextField("status_txt", this.getNextHighestDepth(), 0, 0, 100, 22);
**Error** Scene=Scene 1, layer=Layer 1, frame=1:Line 3: Statement must appear within on handler
var my_sound:Sound = new Sound();
**Error** Scene=Scene 1, layer=Layer 1, frame=1:Line 5: Statement must appear within on handler
my_sound.onLoad = function(success:Boolean) {
**Error** Scene=Scene 1, layer=Layer 1, frame=1:Line 15: Statement must appear within on handler
my_sound.loadSound(_root.musicUrl, true);
Total ActionScript Errors: 4 Reported Errors: 4
I'll keep trying though. Thanks again!
-
Senior Member
Don't do that. Take out the script and put it into the actions on the main timeline. I recommend not to use the on(press) function within buttons at all.
Name the button my_button and then do this:
my_button.onRelease = function(){
script here
}
- The right of the People to create Flash movies shall not be infringed. -
-
heh, I'm sorry, but I'm just not getting it. I'm very new to using flash for things other than simple frame by frame animations.
-
never mind, I got it. thanks!!! I really appreciate the help.
-
ok, one more question. I'd like to make a second button in the same movie (right under the play button) that lets you download the same audio file that the play button uses. Is there a way to link to _root.musicUrl?
This is what I have so far:
http://www.aquateencentral.com/v3/audiotest.html
Thanks!
Last edited by Atarian; 10-11-2005 at 06:00 PM.
-
Just a little bump for the day crowd
-
Senior Member
You link in the same way as in the above script.
- The right of the People to create Flash movies shall not be infringed. -
-
won't that just play the audio when i click the button?
Thanks!
-
Senior Member
not if you create a download script. Check flash help files for the script.
- The right of the People to create Flash movies shall not be infringed. -
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|