Adding sound in actionscript
Hi. I made a simple Quiz and it enters text "Congratulations"
when all 6 questions are correctly answered.
if (score == 6) {
output.text = "Congratulations";
That works OK but now I want to a short sound to come up at
the same time. Tried different arrangements of "addSound" but not
working yet. Any ideas please?
Hello, I'm having a problem with the following code (copied
from smartwebby.com), which is suppose to play music.
my_sound = new Sound();
my_sound.attachSound("mix1");
my_sound.start(0,1000);
gotoAndStop("stop");
I have two swf files. The file with the above code works
correctly when I call it directly. However when I load the movie
into another movie, the music doesn't play. I suspect that I need
to use _root, _parent or this somewhere in this code, but I don't
know where. Please help me correct this code. Thank you very much
for any help you may provide.
Similar Messages
-
I have a pdf file with the added sounds, so I can not run the sound in adobe reader XI on my tablet samsung galaxi pro (android)
Thanks for writing to us. Unfortunately, such advanced javascript support is currently not provided by Adobe Reader for Android.
Thanks,
Adobe Reader Team -
I have just added sound fonts in my library bank, but everytime i try to load a sound tru DLS my logic crashes... Plz help.
cassykeysHave you tried importing them into the EXS 24 ? Assuming the process is the same if you're on Logic X, its just a matter of putting the soundfont files into the ~/Library/Application Support/Logic/Sampler Instruments folder and the EXS converts them when you try to load them - its explained properly in the Software Instruments manual (EXS24 section), but its very quick and easy. It might provide a decent alternative.
-
How To Upload Picture And adding sound
Hi all...
Anyone if you know how to upload picture in java application and adding sound plz try to help me thx..
I need the coding for this 2 for my java application urgently//!!! I am currently using JFrame as my GUI.Eh
Upload a picture, to what? Your PDA, an FTP server, what?
and adding sound to the picture? or just to the application? Do you want a simple "Beep", or more?
I need the coding for this 2 for my java application urgently
Thats nice, I can take it then you have read the [url http://java.sun.com/docs/books/tutorial/index.html]tutorials, search google and the forums, and then posted here? It would be much faster.
I am currently using JFrame as my GUI
Good for you. -
Added sound card, no onboard audio no more
i added an sb live value for the use of the joystick port only, not wanting to use ti as a sound card. the onboard audio of my 865pe neo2 fis2r msi 6728 no longer works. so how can i get back my onboard audio? my speakers are still plugged into the onboard. is this even posible? to use onboard audio, but use my joystick on the sb live card when playing games? or is it only one or the other? do i need to go into the bios maybe and tell it to use onboard audio? like maybe it changed cus of the new sb live value card?
ok, i hooked up my speakers to the sb live card, it's fine i guess , but is it possible to use onboard audio with joystick port only from the live card? or because i have a sound card installed now, does that totally disable onboard completely unless i removed the live card?Yep No is the Answer, Because as soon as Windows Sees that you have a PCI sound card, it will not allow the Onboard sound chips Drivers to Load upon Bootup, I cant believe that you went through the Trouble of Installing a Sound Card that has a "MIDI" port, Instead of just Getting a USB Joystick , as the New USB Joysticks are Much more Responsive and Support Many More Games, and You can Get one For Less $ then you Paid for the Soundblaster .....Sean REILLY875
-
Playing sound using ActionScript 3.0 (newbie)
I have a Flash animation I've created, and at the last minute we have decided to add one audio track to the background. The problem is, I have a looping animation in the timeline, so simply inserting the audio into a layer in the timeline will not work (because it will loop as well).
Can anyone help me with how to insert just one sound file "on top" of all the animations playing using ActionScript 3.0? I've never worked with the Sound class, and have never put audio into a Flash file besides simply importing it into a frame.
THANKS!
JenWorked perfectly. Thank you thank you!
Jen -
I was wondering if there was a way of adding more sounds to the system alert sounds like frog, basso, glass etc? Thanks
Put an aiff audio file into ~/Library/Sounds and it should show up in the Sound Effects preference pane to be chosen as an alert sound.
-
Linkage sound to actionscript in flash cc
Hi,
i have an issue, maybe i dont understand the process well.
- I imported a short mp3 in flash cc library.
- I try to linkage it to actionscript, but i can' t.
- If i click on the sound file, and choose properties, there is no checkbox to export for actionscript.
I see an actionscript tab, but i can' t reach it. I can' t click on it.
- How can i solve this issue ?Try saving this extension to the CC commands directory (I don't use CC, so I can't tell you the exact location, but in CS 6 is C:\Users\{you}\AppData\Local\Adobe\Flash CS6\en_US\Configuration\Commands) and see if it gets you close to what you need. If so, you should be able to edit it to get you the rest of the way:
var doc = fl.getDocumentDOM();
var lib = doc.library;
var selections = lib.getSelectedItems();
if (selections.length > 0) {
//Stolen from Search and Replace by Dave Logan
//so we don't have to enter the parameters every time
var searchFor = '.mp3';
var replaceWith = '_Sound';
searchItems = selections;
nameList = removePath(true);
if (searchItems.length == 0){
alert('No items to replace ".mp3" in');
}else{
for(i = 0; i < searchItems.length; i++){
var searchRegExp = new RegExp(searchFor,"g");
oldname = nameList[i];
newname = oldname.replace(searchRegExp, replaceWith);
searchItems[i].name = newname;
//end stolen/modified code
var newFolder = prompt('Enter folder name to place sound files in', '');
if (newFolder != '') {
lib.newFolder(newFolder);
fl.trace(selections.length);
for (var i=0; i< selections.length; i++) {
var item = selections[i];
fl.trace(item.name);
lib.selectItem(item.name);
if (lib.getItemProperty('linkageImportForRS') == true) {
lib.setItemProperty('linkageImportForRS', false);
lib.setItemProperty('linkageExportForAS', true);
lib.setItemProperty('linkageExportForRS', false);
lib.setItemProperty('linkageExportInFirstFrame', true);
lib.setItemProperty('linkageClassName', item.name);
lib.setItemProperty('compressionType', 'MP3');
if (lib.getItemProperty('useImportedMP3Quality') != undefined) {
lib.setItemProperty('useImportedMP3Quality', true);
if (newFolder != '') {
lib.moveToFolder(newFolder, item.name, true);
//Also stolen from search and replace by Dave Logan
function removePath(bSelItems){
if(bSelItems){
libSelPath=fl.getDocumentDOM().library.getSelectedItems();
}else{
libSelPath=fl.getDocumentDOM().library.items;
itemNames = new Array();
for (a = 0; a < libSelPath.length; a++){
charStart = libSelPath[a].name.lastIndexOf("/") + 1;
itemNames[a] = libSelPath[a].name.substring(charStart);
return itemNames; -
Sound Button, ActionScript 3.0
Hi, I am a newbie to ActionScript but I do have an understanding of scripting. I have worked in designing games on a few game engines and now I am looking into ActionScript 3.0
I created a script by getting some details here and there on the web and this is what Ive come up with,
var loadSnd:URLRequest = new URLRequest("Sound.wav");
var thisSnd:Sound = new Sound();
thisSnd.load(loadSnd);
Sound_1.addEventListener(MouseEvent.CLICK, playF);
function playF(event:MouseEvent);void{
thisSnd:play(); //Line 8
Output:
Scene 1, Layer 'Actions', Frame 1, Line 8
1084: Syntax error: expecting rightbrace before semicolon.
I dont think this is a difficult error to fix but it is an issue for me at the moment.another error in your code:
kglad wrote:
use:
var loadSnd:URLRequest = new URLRequest("Sound.wav");
var thisSnd:Sound = new Sound();
thisSnd.load(loadSnd);
Sound_1.addEventListener(MouseEvent.CLICK, playF);
function playF(event:MouseEvent):void{
thisSnd.play(); //Line 8 -
Adding sound to buttons causes then not to work.
I have a flash project with 3 buttons in each frame 1 button is the correct answer and two are not
here is the code
import flash.events.Event;
btnA.addEventListener(MouseEvent.CLICK, checkCorrectness);
btnB.addEventListener(MouseEvent.CLICK, checkCorrectness);
btnC.addEventListener(MouseEvent.CLICK, checkCorrectness);
function checkCorrectness(e: Event): void {
if (e.target == btnA) {
if (correctA) {
totalscore++;
} else if (e.target == btnB) {
if (correctB) {
totalscore++;
} else if (e.target == btnC) {
if (correctC) {
totalscore++;
score.text = totalscore;
if (totalscore == 18) {
gotoAndStop(21);
return;
nextFrame();
stop();
var totalscore = 0;
var correctA:Boolean = false;
var correctB:Boolean = false;
var correctC:Boolean = false;
score.text=totalscore;
each frame has this code below with the correct answer changing from frame to frame
correctA = true;
correctB = false;
correctC = false;
all works fine but now I have to use sound in the buttons so I duplicated a button and changed the name of one button to "true" and the original I changed to "false".
I added in each of the two new button names a sound effect ( sound 1 for button true and sound 2 for button false)
So the frame list looks like this
frame 1
correctA = true;
correctB = false;
correctC = false;
button name 1 true instance name btnA
button name 2 false instance name btnB
button name 3 false instance name btnC
frame 2
correctA = false;
correctB = true;
correctC = false;
button name 1 false instance name btnA
button name 2 true instance name btnB
button name 3 false instance name btnC
according to this each correct button would trigger sound1 telly the score and move to the next frame
and each incorrect button would also tally the score and move to the next frame.
Not all selections are making the frame move nor the score tally.
any help.
ALL OF THIS WORK FINE WITHOUT THE SOUND AND THE BUTON NAMES CHANGED. SO THE RESULT IS I ONLY HAVE A WORKING FILE BUT WITHOUT THE SOUNDS FOR EACH BUTTON.
RGreat works like a charm, one thing though. Every time I click the Incorrect button button I hear that audio twice . I checked the actual mp3 and it just one sound.
Heres the code you gave me
var correctSound:CorrectSound=new CorrectSound(); // assign this class
var incorrectSound:IncorrectSound=new IncorrectSound(); " "
function checkCorrectness(e: Event): void {
if (e.target == btnA) {
if (correctA) {
totalscore++;
soundF(true);
}else{
soundF(false);
} else if (e.target == btnB) {
if (correctB) {
totalscore++;
soundF(true);
}else{
soundF(false);
} else if (e.target == btnC) {
if (correctC) {
totalscore++;
soundF(true);
}else{
soundF(false);
score.text = totalscore;
if (totalscore == 18) {
gotoAndStop(21);
return;
nextFrame();
function soundF(b:Boolean):void{
if(b){
correctSound.play();
} else {
incorrectSound.play(); -
I am relatively new to Flash and I have taken over a Flash
project that was made out of Movie Clips (.swfs). This was done by
creating the presentation out of 5 separate documents (saved as
.swfs) with a behavior action added to the last frame of each file
telling the movie to load the next external movieclip.
Now that the project is finished, I am not sure if there is
any way to add sound to the file since it is made out of separate
movieclips rather than one long flash document. Everytime the new
movieclip loads, the music will either start over at the beginning
for that document, or stop playing all together. Is there any way
to make the music play continously through all five movies?
Any help will be greatly appreciated!!
Thanks!Fritza8 wrote:
> I am relatively new to Flash and I have taken over a
Flash project that was
> made out of Movie Clips (.swfs). This was done by
creating the presentation out
> of 5 separate documents (saved as .swfs) with a behavior
action added to the
> last frame of each file telling the movie to load the
next external movieclip.
>
> Now that the project is finished, I am not sure if there
is any way to add
> sound to the file since it is made out of separate
movieclips rather than one
> long flash document. Everytime the new movieclip loads,
the music will either
> start over at the beginning for that document, or stop
playing all together. Is
> there any way to make the music play continously through
all five movies?
>
> Any help will be greatly appreciated!!
> Thanks!
Place the music in main level while loading the other content
in level 1.
Levels run independently and while the other movie keep
loading one after
another, it won't interrupt the sound in main level.
Best Regards
Urami
!!!!!!! Merry Christmas !!!!!!!
Happy New Year
<urami>
If you want to mail me - DO NOT LAUGH AT MY ADDRESS
</urami> -
I want to add a short soundclip that plays when my nav bar
loads. I edited down a song in Garageband to 3 seconds, then I
exported it to iTunes. I assume I have to convert it to mp3 to put
it into my Flash file, so my first question is this... how many
kbps should I save the mp3 at? Normally I have mp3's in iTunes that
are 128 or 192, but would this make my swf filesize too big? Can
anyone suggest a setting?
Then, once I convert my mp3 in iTunes, how would I bring it
into my flash file and trigger it so it plays when the nav bar
loads? Thanks!I don't know much about actionscript so please bear with me.
When you say create the sound object, what exactly does that mean?
Where do I put that code? I'd like the sound to trigger after the
preloader loads everything and while the animation plays (logo
flies in, nav bar swoops in from the right, pretty basic). Does
this mean I should put the trigger on frame 3 since the preloader
is taking up the first 2 frames? And does the sound object code go
somewhere different or do I add it above the trigger code on frame
3?
Also, the way I'm setting up my Flash animation is that I'm
going to put the same swf on the top of every one of my html
tables, so every time the user clicks a button in the nav, the nav
bar animation will reload and show the proper page (I'm not doing
my whole site in Flash, just the nav and bringing into
Dreamweaver). It might get a little annoying if the sound plays
each time the user clicks a button, so is there any way to set it
up with Actionscript that the sound only plays when the user
initially goes to the index page? Or will I have to make a separate
swf without the sound and put that on the top of all the other
pages beside the homepage?
With the mp3, I encoded it at 128 and it sounds really good,
I was just wondering if it's overkill just for a 3 second byte.
Does anyone else have any experience with this? I'm really not sure
of what is an appropriate file size, is there a number where I
shouldn't go over? It's a nav bar animation so I'd like it to load
pretty fast. Right now the file is around 85 KB without the sound,
I have no idea whether this is high or low...
Thanks for your help! -
Adding Sound FX...???
Is there a way to add sounds NOT LOOPS but sound effects like for me, I have some WHOOSH sounds I would like to incorporate into a song. I am not sure how to go about importing that file into ST then using it in a song.
A way to do this is by using a JMF player. Check out the JFM forum.
-
Adding sound to game application
Can anyone assist me or provide a link as to how I can add sound to an application(non-applet)? In this case it is a space invaders clone tutorial; now I would like to add sound to when either the player or the aliens fire a laser. The problem is that I'm not sure how to do it. I initially tried using the AudioStream attribute from the sun.audio class but it did not work. Also I would like to add new images to the game background but when I add images to the panel, it does not appear when executed; the game loop I think affects this. Here is some code snippets:
The initial setup function:
public Game() {
//ImagePanel p1 = new ImagePanel(new ImageIcon("City.png").getImage());
// create a frame to contain our game
JFrame container = new JFrame("Space Invaders 101");
// get hold the content of the frame and set up the resolution of the game
JPanel panel = (JPanel) container.getContentPane();
panel.setPreferredSize(new Dimension(800,600));
panel.setLayout(null);
// setup our canvas size and put it into the content of the frame
setBounds(0,0,800,600);
panel.add(this);
// Tell AWT not to bother repainting our canvas since we're
// going to do that our self in accelerated mode
setIgnoreRepaint(true);
// finally make the window visible
container.pack();
container.setResizable(false);
container.setVisible(true);
// add a listener to respond to the user closing the window. If they
// do we'd like to exit the game
container.addWindowListener(new WindowAdapter() {
public void windowClosing(WindowEvent e) {
System.exit(0);
// add a key input system (defined below) to our canvas
// so we can respond to key pressed
addKeyListener(new KeyInputHandler());
// request the focus so key events come to us
requestFocus();
// create the buffering strategy which will allow AWT
// to manage our accelerated graphics
createBufferStrategy(2);
strategy = getBufferStrategy();
// initialise the entities in our game so there's something
// to see at startup
initEntities();
}then the class for firing a shot:
public class ShotEntity extends Entity {
/** The vertical speed at which the players shot moves */
private double moveSpeed = -300;
/** The game in which this entity exists */
private Game game;
/** True if this shot has been "used", i.e. its hit something */
private boolean used = false;
* Create a new shot from the player
* @param game The game in which the shot has been created
* @param sprite The sprite representing this shot
* @param x The initial x location of the shot
* @param y The initial y location of the shot
public ShotEntity(Game game,String sprite,int x,int y) {
super(sprite,x,y);
this.game = game;
dy = moveSpeed;
* Request that this shot moved based on time elapsed
* @param delta The time that has elapsed since last move
public void move(long delta) {
// proceed with normal move
super.move(delta);
// if we shot off the screen, remove ourselfs
if (y < -100) {
game.removeEntity(this);
* Notification that this shot has collided with another
* entity
* @parma other The other entity with which we've collided
public void collidedWith(Entity other) {
// prevents double kills, if we've already hit something,
// don't collide
if (used) {
return;
// if we've hit an alien, kill it!
if (other instanceof AlienEntity) {
// remove the affected entities
game.removeEntity(this);
game.removeEntity(other);
// notify the game that the alien has been killed
game.notifyAlienKilled();
used = true;
}The main game loop:
public void gameLoop() {
long lastLoopTime = System.currentTimeMillis();
// keep looping round til the game ends
while (gameRunning) {
// work out how long its been since the last update, this
// will be used to calculate how far the entities should
// move this loop
long delta = System.currentTimeMillis() - lastLoopTime;
lastLoopTime = System.currentTimeMillis();
// Get hold of a graphics context for the accelerated
// surface and blank it out
Graphics2D g = (Graphics2D) strategy.getDrawGraphics();
g.setColor(Color.black);
g.fillRect(0,0,800,600);
// cycle round asking each entity to move itself
if (!waitingForKeyPress) {
for (int i=0;i<entities.size();i++) {
Entity entity = (Entity) entities.get(i);
entity.move(delta);
// cycle round drawing all the entities we have in the game
for (int i=0;i<entities.size();i++) {
Entity entity = (Entity) entities.get(i);
entity.draw(g);
// brute force collisions, compare every entity against
// every other entity. If any of them collide notify
// both entities that the collision has occured
for (int p=0;p<entities.size();p++) {
for (int s=p+1;s<entities.size();s++) {
Entity me = (Entity) entities.get(p);
Entity him = (Entity) entities.get(s);
if (me.collidesWith(him)) {
me.collidedWith(him);
him.collidedWith(me);
// remove any entity that has been marked for clear up
entities.removeAll(removeList);
removeList.clear();
// if a game event has indicated that game logic should
// be resolved, cycle round every entity requesting that
// their personal logic should be considered.
if (logicRequiredThisLoop) {
for (int i=0;i<entities.size();i++) {
Entity entity = (Entity) entities.get(i);
entity.doLogic();
logicRequiredThisLoop = false;
// if we're waiting for an "any key" press then draw the
// current message
if (waitingForKeyPress) {
g.setColor(Color.white);
g.drawString(message,(800-g.getFontMetrics().stringWidth(message))/2,250);
g.drawString("Press any key",(800-g.getFontMetrics().stringWidth("Press any key"))/2,300);
// finally, we've completed drawing so clear up the graphics
// and flip the buffer over
g.dispose();
strategy.show();
// resolve the movement of the ship. First assume the ship
// isn't moving. If either cursor key is pressed then
// update the movement appropraitely
ship.setHorizontalMovement(0);
if ((leftPressed) && (!rightPressed)) {
ship.setHorizontalMovement(-moveSpeed);
} else if ((rightPressed) && (!leftPressed)) {
ship.setHorizontalMovement(moveSpeed);
// if we're pressing fire, attempt to fire
if (firePressed) {
tryToFire();
// finally pause for a bit. Note: this should run us at about
// 100 fps but on windows this might vary each loop due to
// a bad implementation of timer
try { Thread.sleep(10); } catch (Exception e) {}
for basic sounds, you can use the JavaSound API.
http://java.sun.com/docs/books/tutorial/sound/index.html
There are plugin libraries available that add MP3 and OGG support to it.
http://www.javazoom.net/index.shtml -
Adding sound to my presentation.
Hi guys,
I am new to making keynote presentation. I've been using powerpoint.
Keynote is a lot like powerpoint and imovie mixed together. it is so easy to make and i like it a lot.
Do you know how we could put the sound to the presentation?
Thanks,
IchieWelcome to the forums!
You can add various sounds to individual slides by dragging and dropping the sound onto the slide -- use the Build Inspector to control when the sound "builds in" and thus plays.
You can also specify a set of songs/sounds to play across an entire presentation -- this is set in the Document Inspector. You can specify a single sound/song, or an entire iTunes playlist.
Maybe you are looking for
-
"The Itunes library file cannot be saved" Error Message (-54) please help!
Hello, I was loading a music cd onto my itunes library today when I started getting this recurring Error message stating: "The Itunes library file cannot be saved. An unknown error has occurred (-54)" It just keeps popping up, and now it let me play
-
How to change country in my profile?
i was not aloud to buy Lightroom5 as of "some errors" in my personal data: i supppose my card issied in RUssia, and address I indicated was my US office place. How to change the country in my profail to Russia now?
-
Can i sync Iphone contacts to my macbook?
I have an iphone and I dont use my phonebook on my macbook much but it be great if I can sync my contacts from my phone to my computer. Is that possible???
-
TCP architecture advice and suggestions
Hello All, Just trying to come up with some ideas for architecture implementation. I am needing to communicate to multiple cRIO modules and typical use TCP in the past to communicate with each cRIO module. I now have the problem of having multiple
-
Component reference point in ultiboard
The default setting for component reference point is the center of PIN 1 of the part. however, for many SMT machines, it reference to the center of the component (not a pin). How doImodify it without going through every component in the database? So