Delay On Playing Sound In Actionscript 3 Problem
good day,
My problem is that everytime an object (obj1) hits another object (obj2) a sound will play instantly as the object collides, but the sound will played with a delay of .5sec .
Does anybody know how to make this play instantly?
- newbie here - ^_^
Thanks
KirupaForum > Flash > ActionScript 3.0
Posted on: 08-19-2008, 11:02 AM
View Complete Forum Thread with Replies
Sponsored Links:
How To Delay Sound From Playing?
Code:
var tl:TheLoop = new TheLoop();
tl.play(2, 1000);
When I have this in the first frame, as soon as I test the movie the sound plays. How do I make it pause for 2 seconds before playing? I thought this would work but it still plays immediately.
View Replies !
View Related
Playing A Sound On Each Frame With Actionscript
I'm new to Flash. I'm building a simple presentation that the user clicks on the 'Forward' button and it goes to the next frame, shows some graphics and text, and plays an mp3 audio track. I'd like to put the audio tracks on my website.
I'm using the 'NextFrame' command for the forward button. On the individual frames I'm trying to use this, but it doesn't play the sound. Can anyone see a problem with this?
mysound.loadSound("http://www.mywebsite.com/html/FlashSounds/test.mp3", True)
mysound.start
stop();
BTW - could the 'stop' command be shutting down the sound? I'm new to this... thanx
Ronm
View Replies !
View Related
Coll Idea For Playing Sound But Need Actionscript Help
I have an idea to have a custom mp3 player using the fisheye gallery downloaded here. http://="http://www.flashmo.com/prev...o_133_fisheye"
In the gallery downloaded, it is set up to where each image thumbnail is a link to a web site. I would like to change that. What i wanted to do was have each thumbnail load a song when clicked and stop the previous song when the next thumbnail is clicked. What I have gotten so far is every thumbnail loading the same song. I am new to AS3 so my approach was very basic. I know there has to be a way to set up a bigger picture than the method I am using. I'm not sure how to set it up to where each thumbnail plays a different song but i'm guessing it has to do with the xml file that goes with the gallery. If anyone has any ideas how to set this up I would really appreciate it.
Here is the ActionScript placed on the first frame of the gallery file.
Code:
stop();
import fl.transitions.Tween;
import fl.transitions.easing.*;
var filename_list = new Array();
var url_list = new Array();
var url_target_list:Array = new Array();
var title_list = new Array();
var description_list = new Array();
var i:Number;
var j:Number;
var tn:Number = 0;
var default_scale:Number = 0.6;
var new_scale:Number;
var center_x:Number = tn_group_mask.x + tn_group_mask.width * 0.5;
var half_of_tn_width:Number = 80;
var current_mc:MovieClip;
var total:Number;
var flashmo_xml:XML = new XML();
var folder:String = "thumbnails/";
var xml_loader:URLLoader = new URLLoader();
xml_loader.load(new URLRequest("flashmo_129_thumbnail_list.xml"));
xml_loader.addEventListener(Event.COMPLETE, create_thumbnail);
var thumbnail_group:MovieClip = new MovieClip();
addChild(thumbnail_group);
thumbnail_group.mask = tn_group_mask;
thumbnail_group.x = tn_group.x;
thumbnail_group.y = tn_group.y;
tn_group.visible = false;
tn_title.text = "";
tn_desc.text = "";
tn_url.text = "";
function create_thumbnail(e:Event):void
{
flashmo_xml = XML(e.target.data);
total = flashmo_xml.thumbnail.length();
for( i = 0; i < total; i++ )
{
filename_list.push( flashmo_xml.thumbnail[i].@filename.toString() );
url_list.push( flashmo_xml.thumbnail[i].@url.toString() );
url_target_list.push( flashmo_xml.thumbnail[i].@target.toString() );
title_list.push( flashmo_xml.thumbnail[i].@title.toString() );
description_list.push( flashmo_xml.thumbnail[i].@description.toString() );
}
load_tn();
addEventListener(Event.ENTER_FRAME, fisheye );
}
function load_tn():void
{
var pic_request:URLRequest = new URLRequest( folder + filename_list[tn] );
var pic_loader:Loader = new Loader();
pic_loader.load(pic_request);
pic_loader.contentLoaderInfo.addEventListener(Event.COMPLETE, on_loaded);
tn++;
}
function on_loaded(e:Event):void
{
if( tn < total )
{
load_tn();
}
var flashmo_bm:Bitmap = new Bitmap();
var flashmo_mc:MovieClip = new MovieClip();
flashmo_bm = Bitmap(e.target.content);
flashmo_bm.x = - flashmo_bm.width * 0.5;
flashmo_bm.y = - flashmo_bm.height * 0.5;
flashmo_bm.smoothing = true;
var bg_width = flashmo_bm.width + 10;
var bg_height = flashmo_bm.height + 10;
flashmo_mc.addChild(flashmo_bm);
flashmo_mc.graphics.lineStyle(1, 0x666666);
flashmo_mc.graphics.beginFill(0xFFFFFF);
flashmo_mc.graphics.drawRect( - bg_width * 0.5, - bg_height * 0.5, bg_width, bg_height );
flashmo_mc.graphics.endFill();
flashmo_mc.name = "flashmo_" + thumbnail_group.numChildren;
flashmo_mc.buttonMode = true;
flashmo_mc.addEventListener( MouseEvent.MOUSE_OVER, tn_over );
flashmo_mc.addEventListener( MouseEvent.MOUSE_OUT, tn_out );
flashmo_mc.addEventListener( MouseEvent.CLICK, tn_click );
flashmo_mc.scaleX = flashmo_mc.scaleY = default_scale;
flashmo_mc.x = thumbnail_group.numChildren * 94;
thumbnail_group.addChild(flashmo_mc);
}
function tn_over(e:MouseEvent):void
{
var mc:MovieClip = MovieClip(e.target);
var s_no:Number = parseInt(mc.name.slice(8,10));
if( s_no > 1 )
thumbnail_group.addChild( thumbnail_group.getChildByName("flashmo_" + (s_no-2) ) );
if( s_no > 0 )
thumbnail_group.addChild( thumbnail_group.getChildByName("flashmo_" + (s_no-1) ) );
if( s_no < thumbnail_group.numChildren - 2 )
thumbnail_group.addChild( thumbnail_group.getChildByName("flashmo_" + (s_no+2) ) );
if( s_no < thumbnail_group.numChildren - 1 )
thumbnail_group.addChild( thumbnail_group.getChildByName("flashmo_" + (s_no+1) ) );
thumbnail_group.addChild( mc );
tn_title.text = title_list[s_no];
tn_desc.text = description_list[s_no];
tn_url.text = url_list[s_no];
}
function tn_out(e:MouseEvent):void
{
tn_title.text = "";
tn_desc.text = "";
tn_url.text = "";
}
//Here is my method to play sound when clicked but it only loads one sound for every thumbnail.\
function tn_click(e:MouseEvent):void
{
var mc:MovieClip = MovieClip(e.target);
var s_no:Number = parseInt(mc.name.slice(8,10));
var s:Sound = new Sound(new URLRequest("Sound.mp3"));
var sc:SoundChannel = s.play();
addEventListener(Event.ENTER_FRAME, loop);
function loop(e:Event):void
{
if(sc.position > 20000)
SoundMixer.stopAll();
}
}
function fisheye(e:Event):void
{
thumbnail_group.x -= ( mouseX - center_x ) * 0.05;
if( thumbnail_group.x > tn_group_mask.x + half_of_tn_width )
{
thumbnail_group.x = tn_group_mask.x + half_of_tn_width;
}
else if( thumbnail_group.x < tn_group_mask.x - thumbnail_group.width + tn_group_mask.width )
{
thumbnail_group.x = tn_group_mask.x - thumbnail_group.width + tn_group_mask.width;
}
if( mouseY > tn_group_mask.y && mouseY < tn_group_mask.y + tn_group_mask.height )
{
for( j = 0; j < thumbnail_group.numChildren; j++ )
{
current_mc = MovieClip(thumbnail_group.getChildAt(j));
var distance:Number = Math.sqrt(
Math.pow( Math.abs( stage.mouseX - (current_mc.x + thumbnail_group.x) ) , 2)
+ Math.pow( Math.abs( stage.mouseY - (current_mc.y + thumbnail_group.y) ) , 2)
);
new_scale = 1 - ( distance * 0.002 );
current_mc.scaleX += (new_scale - current_mc.scaleX) * 0.2;
current_mc.scaleY += (new_scale - current_mc.scaleY) * 0.2;
if( current_mc.scaleX < default_scale )
current_mc.scaleX = current_mc.scaleY = default_scale;
}
}
else
{
for( j = 0; j < thumbnail_group.numChildren; j++ )
{
current_mc = MovieClip(thumbnail_group.getChildAt(j));
current_mc.scaleX += (default_scale - current_mc.scaleX) * 0.2;
current_mc.scaleY += (default_scale - current_mc.scaleY) * 0.2;
}
}
}
And here is the XML that goes with this gallery. How could I incorperate the song being played for each one?
Code:
<?xml version="1.0" encoding="utf-8"?>
<thumbnails>
<thumbnail filename="flashmo_128_elegant.jpg" url="http://www.flashmo.com/preview/flashmo_128_elegant" target="_parent"
title="Item No. 1 (128 elegant)"
description="Elegant Design - Flash website template, subpages for products, AS3 contact form" />
<thumbnail filename="flashmo_127_curtain.jpg" url="http://www.flashmo.com/preview/flashmo_127_curtain" target="_parent"
title="Item No. 2 (127 curtain)"
description="Curtain template for making simple Flash websites including ActionScript 3 + PHP contact form" />
<thumbnail filename="flashmo_126_envelope.jpg" url="http://www.flashmo.com/preview/flashmo_126_envelope" target="_parent"
title="Item No. 3 (126 envelope)"
description="Envelope Template with drag N drop Flash photo gallery, ActionScript 3.0" />
<thumbnail filename="flashmo_125_girls.jpg" url="http://www.flashmo.com/preview/flashmo_125_girls" target="_blank"
title="Item No. 4 (125 girls)"
description="The Girls - Fashion Style Flash Template with a background music loop" />
<thumbnail filename="flashmo_124_delicious.jpg" url="http://www.flashmo.com/preview/flashmo_124_delicious" target="_blank"
title="Item No. 5 (124 delicious)"
description="Delicious Food - Restaurant Template made in Flash CS3, ActionScript 3" />
<thumbnail filename="flashmo_123_business.jpg" url="http://www.flashmo.com/preview/flashmo_123_business" target="_blank"
title="Item No. 6 (123 business)"
description="Business Template built on Flash ActionScript 3 including email contact form" />
<thumbnail filename="flashmo_122_3d_curve_gallery.jpg" url="http://www.flashmo.com/preview/flashmo_122_3d_curve_gallery" target="_parent"
title="Item No. 7 (122 3d curve gallery)"
description="3D Curve Flash Photo Gallery using Papervision3D and XML" />
<thumbnail filename="flashmo_121_3d_grid_gallery.jpg" url="http://www.flashmo.com/preview/flashmo_121_3d_grid_gallery" target="_parent"
title="Item No. 8 (121 3d grid gallery)"
description="3D Grid - Flash Photo Gallery using Papervision3D and XML" />
<thumbnail filename="flashmo_120_artwork.jpg" url="http://www.flashmo.com/preview/flashmo_120_artwork" target="_parent"
title="Item No. 9 (120 artwork)"
description="Artwork Flash Website - Dynamic XML Gallery, Free Templates" />
<thumbnail filename="flashmo_119_swimwear.jpg" url="http://www.flashmo.com/preview/flashmo_119_swimwear" target="_blank"
title="Item No. 10 (119 swimwear)"
description="Swimwear flash website, beautiful transition effects" />
<thumbnail filename="flashmo_118_fashion_gallery.jpg" url="http://www.flashmo.com/preview/flashmo_118_fashion_gallery" target="_blank"
title="Item No. 11 (118 fashion gallery)"
description="Fashion Gallery - XML photo gallery for models, simple transitions, and contact form" />
<thumbnail filename="flashmo_117_artistic.jpg" url="http://www.flashmo.com/preview/flashmo_117_artistic" target="_self"
title="Item No. 12 (117 artistic)"
description="Artistic flash website, XML product list, XML news scroller, flash contact form, smooth sliding transitions" />
<thumbnail filename="flashmo_116_dream.jpg" url="http://www.flashmo.com/preview/flashmo_116_dream" target="_self"
title="Item No. 13 (116 dream)"
description="Dream Flash website, XML news list, subpages for services, email form" />
<thumbnail filename="flashmo_116_pinky.jpg" url="http://www.flashmo.com/preview/flashmo_116_pinky" target="_self"
title="Item No. 14 (116 pinky)"
description="Pinky flash template, XML news list, subpages, contact form" />
<thumbnail filename="flashmo_115_scroller.jpg" url="http://www.flashmo.com/preview/flashmo_115_scroller" target="_parent"
title="Item No. 15 (115 scroller)"
description="Flash XML Scroller for news and announcement section, product list, portfolio list" />
<thumbnail filename="flashmo_114_horizontal_menu.jpg" url="http://www.flashmo.com/preview/flashmo_114_horizontal_menu" target="_parent"
title="Item No. 16 (114 horizontal menu)"
description="Flash XML horizontal menu, animated buttons, rollover effects" />
<thumbnail filename="flashmo_113_vertical_menu.jpg" url="http://www.flashmo.com/preview/flashmo_113_vertical_menu" target="_parent"
title="Item No. 17 (113 vertical menu)"
description="Flash XML menu vertical - glossy menu, animated menu" />
<thumbnail filename="flashmo_112_news_tab.jpg" url="http://www.flashmo.com/preview/flashmo_112_news_tab" target="_parent"
title="Item No. 18 (112 news tab)"
description="Flash XML news tab, news reader, number tabs, auto play" />
<thumbnail filename="flashmo_111_butterfly_studio.jpg" url="http://www.flashmo.com/preview/flashmo_111_butterfly_studio" target="_parent"
title="Item No. 19 (111 butterfly studio)"
description="Butterfly studio flash template including subpages" />
<thumbnail filename="flashmo_110_flower.jpg" url="http://www.flashmo.com/preview/flashmo_110_flower" target="_parent"
title="Item No. 20 (110 flower)"
description="Flower company template, rotating flower animation" />
<thumbnail filename="flashmo_109_rectangular.jpg" url="http://www.flashmo.com/preview/flashmo_109_rectangular" target="_parent"
title="Item No. 21 (109 rectangular)"
description="Rectangular portfolio flash template with simple motion tweens" />
<thumbnail filename="flashmo_108_studio.jpg" url="http://www.flashmo.com/preview/flashmo_108_studio" target="_parent"
title="Item No. 22 (108 studio)"
description="Studio template including XML portfolio list and flash email form" />
<thumbnail filename="flashmo_107_slider.jpg" url="http://www.flashmo.com/preview/flashmo_107_slider" target="_parent"
title="Item No. 23 (107 slider)"
description="Flash XML Product Slider with auto play mode" />
<thumbnail filename="flashmo_106_color_wave.jpg" url="http://www.flashmo.com/preview/flashmo_106_color_wave" target="_parent"
title="Item No. 24 (106 color wave)"
description="Color Wave Studio, flash portfolio template, email form" />
</thumbnails>
Thanks in advance to anyone who can help.
View Replies !
View Related
When A Sound Stops Playing So It Can Start Playing Another Sound :Monitoring Playback
I'm attempting to do a very simple thing and I'm very perplexed. My girlfriend is an opera singer and all I'm trying to do is advance the audio track when the song finishes playing to go to the next frame. On the surface it seems easy, however I can't seem to figure it out. Perhaps you can help?
Check out the movie here: http://www.earthgrid.com/earthgrid/valentina.html
Here's my code its on frame 2 in the movie
Code:
stopallsounds();
s2.close();
s3.close();
var s1:Sound = new Sound();
s1.loadSound("Agnus_Dei.mp3", true);
s1.start();
stop();
Explanation:: the flash movie has buttons that allow you to navigate between the 3 different music tracks.
when you click on a button, first I close the loading of the previous track, ie. s2 and s3, if they are still loading.
What I'd like to do is insert a command that advances to the next track (which happens to be on the following frame, 3) ONLY when the first audio track is finished PLAYING, not finished 'loading'
something like:
s.addEventListener(Event.SOUND_COMPLETE, gotoandplay (3);
);
so that when Agnus Dei finishes playing it goes to the next frame which starts the next track.
but that' doesn't seem to work.
I found this URL in Adobe's support site:
http://livedocs.adobe.com/flash/9.0/main/wwhelp/wwhimpl/common/html/wwhelp.htm?context=LiveDocs_Parts&file=00000283.ht ml
it says this:
Your application might want to know when a sound stops playing so it can start playing another sound, or clean up some resources used during the previous playback. The SoundChannel class dispatches an Event.SOUND_COMPLETE event when its sound finishes playing. Your application can listen for this event and take appropriate action, as shown below:
Code:
import flash.events.Event;
import flash.media.Sound;
import flash.net.URLRequest;
var snd:Sound = new Sound("smallSound.mp3");
var channel:SoundChannel = snd.play();
s.addEventListener(Event.SOUND_COMPLETE, onPlaybackComplete);
public function onPlaybackComplete(event:Event)
{
trace("The sound has finished playing.");
}
>> However, when I try to paste in this code into a frame in Flash CS3 it gives an error saying I have to put it in a 'package'
I tried that, putting this code into a file and saving it as a .as file
I really don't get how to do this Package thing in CS3, so I couldnt get the example to work.
If so please contact me Please help!
View Replies !
View Related
How To Delay Playing?
I'm trying have a MC fade in (MC name is i001 in the example below and is placed directly on the stage) upon entering the frame (this part of my AS works) and then wait a little (up to 150 frames in the instance below) before moving to the next frame of the _root.
My guess is that the line with gotoAndPlay(_currentframe+1) is the one with the error. I tried replacing this with just play() but that doesn't work either.
ActionScript Code:
onClipEvent(load) {
fadein = 0;
}
onClipEvent(enterFrame) {
_root.i001._alpha = fadein;
fadein += _root.fadeinstep;
timer += 1;
if (timer >= 150) {
gotoAndPlay(_currentframe +1);
}
}
My "action" layer frame contains the stop(); command.
Anybody can help me?
Thanks in advance,
JR G.
View Replies !
View Related
Delay Before Playing An Action
It may be super simple but it's 4 am and I'm almost asleep . What I need is an actionscript code that will delay another action from happening x seconds.
For example:
I want to load a movie clip let's call it load1_mc and then after load1_mc loads I input a delay command that will wait x seconds before loading load2_mc and so on.
onEnterFrame
_parent.load1_mc.loadMovie("test.swf");
*Delay Function/Command Here*
_parent.load2_mc.loadMovie("test2.swf");
-----------------------------------------------------------------------
I'm almost sure there must be a simple way of doing it, but I just can't think of one now. Maybe the setInterval() instruction... I dunno. The idea is for loading mc's like the example above or any other "actions" I can think off without relying on frames.
Any help will be appreciated.
View Replies !
View Related
One-frame Playing Of 3 Movieclips - With A Delay Between Each One
I have 3 movieclips in the first frame, but the movieclips each have their own layer..
See attached movie.
Please - I want a code to play the first movieclip and then 4 seconds pause - then play the second movieclip and 4 seconds pause - and when the third movieclip ends it should go to first movieclip and start all over again.
I want it all to be in one frame because I had trouble with getting it to work properly over 3 frames.
See attached movie. If anybody could write the code in to the movie it would be nice. I have struggled with this for a long time.
View Replies !
View Related
How To Start Playing Many Clips With A Different Delay For Each One?
Hi,
I have, let's say, 50 occurences of the same movieClip (a ball changing color) and I want to play them all with one click BUT not at the same time, so I need to put a different delay on each clip.
I use the following code to catch all my movieClip but then don't know how to play them with delay...
Code:
for (x in atomMain_mc){
var myMcs:Object = atomMain_mc[x];
if (typeof(myMcs) == "movieclip"){
myMcs.play();
}
thanks for helping....
View Replies !
View Related
Unwanted Delay When Playing A Movieclip
I have a swf that loads a movieclip which basically just plays a sound. The movieclip is set to play the sound, then gotoAndStop on the start frame for the sound. This is so it will be ready to replay the sound should the need arise.
I have a repeat button in the main swf that the user can click to play the sound from the movieclip again. The code in this button is simply _root.movieclip.play();
This works fine except that there is a 4-5 second delay from when you hit the button and the sound actually starts to play. Does anyone have any idea what could be causing this delay? I've been searching my code all night and can't find anything that could be wrong...it is just a simple play command. I've tried changing it to gotoAndPlay with the appropriate frame number but it still has the long delay.
Any ideas?
View Replies !
View Related
How Can I Delay A Movie Clip From Playing 5 Seconds
I am new to flash and am having a little bit of trouble. I have 3 movie clips i would like to start 5 seconds after the last movie clip started. I would like movie clip 1 to start instantly the 2nd movie clip to start 5 seconds later and the 3rd movie clip to start 10 second later. Any help is much appreciated.
View Replies !
View Related
Delay Movieclip From Playing On Button Click
Hello
I'm sure there is an easy answer to this question, but for the life of me I can't figure it out.
I have a button in flash that onRelease causes one "animation to play" and "another to stop"
I also want this same button to call another movieclip but I want that movieclip delayed some so that "animation to play" can finish.
I would just call the second movieclip from the first animation but there are other buttons that trigger both "animation to play" and "another to stop" but trigger different delayed clips.
I have this:
Code:
on (release) {
_root.sat.beam.gotoAndStop(1);
_root.sat.gotoAndPlay(21);
var obj = new Object("_root.pages");
obj.interval = function(s) {
trace(s);
_root.pages.gotoAndStop(2);
};
setInterval(obj, "interval", 6500, "interval called");
}
and it actually works !!! but it keeps calling the interval at every "6500" after that. It does not seem to effect the movie in a bad way, but I only want it to call the interval once for every button release.
So I guess my question is if/how can this be achieved, or is there a better way alltogether?
Thank
Johnny
View Replies !
View Related
Flash Player Not Playing Not Playing Properly Low Bitrate Sound
Hi,
I have created a flash audio player which can play streaming audio (mp3) files and it takes data from external xml file. Everthing is working fine. But when i used a low bitrate mp3 file (size 600 kb, time 3min approx) , it plays the audio with max speed and get ended in 30 seconds. The same audio file is playing normally in windows media player, or winamp,etc.
Plese give me some idea what is happening ........
Thanks,
Gunjan
View Replies !
View Related
How Do I Check To See If A Sound Is Already Playing Before Playing When Pressing Play
Okay, i really need some help on this. I have a play button where if clicked will play the sound over the top of it when its already playing, if that makes any sense. the sound is already called on the first frame. if the user clicks the play button again, it will play over it.
heres my play button code. i need to know what to add to add to make it check to see if the audio is already playing. My audio sound is named myMusc.
ActionScript Code:
on (press) {
if (playing != true) {
if (paused != true) {
playing = true;
paused = false;
stopped = false;
myMusic.start(0, 999);
}
if (paused == true) {
playing = true;
paused = false;
stopped = false;
myMusic.start(myMusicPosition, 0);
_root.myMusic.onSoundComplete = function() {
myMusic.start();
};
}
}
}
Thanks
View Replies !
View Related
How To Know If My Sound Is Playing Or Finished Playing?
I`m loading and playing sound like below.
Code:
//SOUND LOAD
var snd:Sound = new Sound();
snd.load(new URLRequest("sound.mp3"));
snd.addEventListener(IOErrorEvent.IO_ERROR, onIOError, false, 0, true);
snd.addEventListener(Event.COMPLETE, onSoundLoadComplete, false, 0, true);
function onIOError(evt:IOErrorEvent):void{
trace("sound loading error: ",evt.text);
}
function onSoundLoadComplete(evt:Event):void{
trace("sound loaded");
}
//SOUND PLAY
snd_btn1.addEventListener(MouseEvent.MOUSE_OVER,sndPlay);
function sndPlay(evt:Event):void{
var channel:SoundChannel
channel = snd.play();
}
i would like to have my sound to play only when it`s not already playing.
how can I achieve this?
thank you
View Replies !
View Related
How To Know If My Sound Is Playing Or Finished Playing?
I`m loading and playing sound like below.
Code:
//SOUND LOAD
var snd:Sound = new Sound();
snd.load(new URLRequest("sound.mp3"));
snd.addEventListener(IOErrorEvent.IO_ERROR, onIOError, false, 0, true);
snd.addEventListener(Event.COMPLETE, onSoundLoadComplete, false, 0, true);
function onIOError(evt:IOErrorEvent):void{
trace("sound loading error: ",evt.text);
}
function onSoundLoadComplete(evt:Event):void{
trace("sound loaded");
}
//SOUND PLAY
snd_btn1.addEventListener(MouseEvent.MOUSE_OVER,sndPlay);
function sndPlay(evt:Event):void{
var channel:SoundChannel
channel = snd.play();
}
i would like to have my sound to play only when it`s not already playing.
how can I achieve this?
thank you
View Replies !
View Related
How To Know If My Sound Is Playing Or Finished Playing?
I`m loading and playing sound like below.
Code:
//SOUND LOAD
var snd:Sound = new Sound();
snd.load(new URLRequest("sound.mp3"));
snd.addEventListener(IOErrorEvent.IO_ERROR, onIOError, false, 0, true);
snd.addEventListener(Event.COMPLETE, onSoundLoadComplete, false, 0, true);
function onIOError(evt:IOErrorEvent):void{
trace("sound loading error: ",evt.text);
}
function onSoundLoadComplete(evt:Event):void{
trace("sound loaded");
}
//SOUND PLAY
snd_btn1.addEventListener(MouseEvent.MOUSE_OVER,sndPlay);
function sndPlay(evt:Event):void{
var channel:SoundChannel
channel = snd.play();
}
i would like to have my sound to play only when it`s not already playing.
how can I achieve this?
thank you
View Replies !
View Related
Sound Delay
Hi,
I searched the boards and didnt find my issue, so if I missed it, a link would be appreciated.
I have a flash 9 movie, but its been a problem since 8. For some reason when i tell a sound to .start() it lags for a couple seconds before finishin up the code. On my site this almost looks like a hang up and Id like to be able to play sounds w/o any severe drop in performance.
effectively, this is the code Im using:
startSound = new Sound();
startSound.attachSound("Start");
if (soundsOn){ /////Plays welcome sound, if on
startSound.start();
}
If sounds are on and i run a getTimer() before and after that snippet there is a way noticable gap. For a demo goto http://beta.PhilHarlow.com?e=fk1 click on settings on the desktop or start menu, open performance, and turn souds on and off. An alert that triggers a sound pops up, and by turning sounds off and on you can see the big difference.
Does anyone know why this is, or more importantly, a fix or work around?
Thanks FK!
View Replies !
View Related
Sound Delay
Hi
I'm new to flash so any help would be greatly appreciated ,
I have a created a swf file which includes a recorded mp3 voiceover. When I publish the movie and view the swf file the sound plays in time with my animation. However when I view the swf file through a html page there is a sound delay of a few seconds. Could anyone shed some light on why this is happening and how I can overcome it?
Cheers.
View Replies !
View Related
Sound Delay
Hi
I'm making a game and I think I'm usuing a pretty standard way of playing sounds, just an example:
ActionScript Code:
wSound = new Sound(this);
wSound.attachSound("fxPistol");
wSound.start(0, 1);
wSound.setVolume(40*_root.masterVolume);
Anyway, the problem is that all sounds have a delay of about 1 second, which sometimes sounds very wrong (the above example is for pistol fire, which requires exact sound timing).
I can't think why there would be a delay, the game itself isn't running slowly. If anyone could just suggest any possible cause I'd appreciate it.
View Replies !
View Related
Sound Delay?
I have a button calling an external mp3 to play.
on (release) {
yesSound = new Sound ();
yesSound.loadSound("http://www.myurl.com/yes.mp3", true);
}
Even with streaming on "true" there is an 8 second delay before the song begins.
If I just go to the url in the browser -- the song begins instantly.
What am I doing wrong...any ideas?
Thx!
wnf
View Replies !
View Related
Sound Delay
I am incorporating a background music loop to a site im working on but the music delays about 30 seconds before it begins to play. It's an external movie clip which I even load in the very first (techically third because of the preloader script) keyframe and then unload just so the computer can have it ready to go.
~ First of all: is this delay happening on all of your guys computers or just my messed up one....
~ Secondly, how do I get it to come in exactly when the final layout is opened?
See it here:
http://www.rawkandchita.com
Just for clarification: not the original sound but the music that plays with the equalizer at the end.
Thanks guys
~ Seretha
View Replies !
View Related
Delay Sound
I have a page that has sound, but I would for it to play about 1 or 2 seconds after the page loads, can someone tell me how I can do this?
Thanks
View Replies !
View Related
Sound Delay
Hey guys,
Is there a way to tell a sound to delay a second or half a second before it starts playing?
I know you can set and offset so the sound starts in the middle but what i want is for the sound to start from the beginning after waiting for half a second.
Any suggestions?
Thanks
Tyler
View Replies !
View Related
Sound Delay
I am incorporating a background music loop to a site im working on but the music delays about 30 seconds before it begins to play. It's an external movie clip which I even load in the very first (techically third because of the preloader script) keyframe and then unload just so the computer can have it ready to go.
~ First of all: is this delay happening on all of your guys computers or just my messed up one....
~ Secondly, how do I get it to come in exactly when the final layout is opened?
See it here:
http://www.rawkandchita.com
Just for clarification: not the original sound but the music that plays with the equalizer at the end.
Thanks guys
~ Seretha
View Replies !
View Related
Delay Sound
I have a page that has sound, but I would for it to play about 1 or 2 seconds after the page loads, can someone tell me how I can do this?
Thanks
View Replies !
View Related
Sound Delay
Hey guys,
Is there a way to tell a sound to delay a second or half a second before it starts playing?
I know you can set and offset so the sound starts in the middle but what i want is for the sound to start from the beginning after waiting for half a second.
Any suggestions?
Thanks
Tyler
View Replies !
View Related
Stoping And Playing Sound At A Particular Point (using Sound Object)
Hi,
I have a movie in which i have a voice over and some animations which is in sync with the VO. I have a play button and stop button.
I am using the sound object method to play the sound and the animations are in timeline.
I have to stop the movie at any point in time and when i click on play the sound should start from the point where it stopped..But it is not happening.
Please help me..
am having a deadline today..
lamus
View Replies !
View Related
Sound Delay In Flash 5
(I regret having to start with this, but, as always: don't get on my back about using Flash 5. I'd use MX if it didn't randomly crash on my computer).
What I'm trying to do is have a short intro clip before a loop begins. So the initial sound clip plays, then as soon as it finishes, the loop begins. I can't find a way to do it, but can I either make a sound delay for x milliseconds after the start command, or have an event that is triggered when the first clip stops playing? thx.
View Replies !
View Related
Delay Sound File
what i'd like to do...
my mp3 is say 50secs long. what i want is another Mp3 to start at 40secs into the first one so they overlap. So basically 2 mp3 constantly overlapping.
how can i tweek this code
mySound = new Sound();
mySound.loadSound("music.mp3",true);
mySound.start();
mySound.setVolume (50);
mySound.onSoundComplete = function(){
mySound.start(0,999);
}
thnx
View Replies !
View Related
Sound To Scene Delay
Hay,
I'm new at this, but would appreciate it if someone can tell me the script i need to write for the following:
A wav sound plays when you click on a symbel and then goes to a scene. I wrote a behaviour that plays the sound and a action that takes you to the appropriate scene.
What I want is to let the sound finish before you go to the scene... a sort of delay until the sound file is done.
any help?
View Replies !
View Related
Progressive Sound Delay
Hello,
My site and I recently released part one of our cartoon trilogy. It was more or less well recieved but the biggest comment we got was how distracting the audio syncing. When I test the movie scene by scene in Flash the syncing is dead one but when I test/publish/export the movie and watch it in its completion the audio syncing slowly goes off throughout the movie eventually being almost a full second ahead.
So, if anyone has any suggestions how to correct this please let me know as it looks really bad and any timed gags are completely lost because of the terrible syncing. If you want to see what I'm talking about you can go see the cartoon here.
Thanks,
Dain
View Replies !
View Related
Looping Sound Without Delay
Hello buddies
I wanna play a loop mp3 file without any dely between each time that loop wanna start .
for exam with this code
a=new Sound(this)
a=attachSound("mp3")
a.start(0,9999)
------------
But in above each time mp3 wanna play a short delay happen!
Is there any scape from this delay?
View Replies !
View Related
Looping A Sound With No Delay
I'm working on a site, and I want the music in it to loop. The original sound file had a slight flat delay before any sound, this caused a slight sound gap between loops, whereas when it looped for about half a second there was no sound.
So i went about editing the sound file, so there was no flat line before it started. I did this and saved it. But when I import it into Flash, it seems to create a sound gap.
So basically, im asking is there anyway to get rid of this so the loops are seemless?
View Replies !
View Related
How Set Sound Reload Delay
Okay, I am very new to actionscript and actually I am making my very first flash game so forgive me if this is a really stupid question. I am making a shooter game and the problem is I cannot figure out how make the "Shotgun" sound delay before it plays again. In fact, it would even be an improvement if it would just not be able to play at the same time as itself. As it is now, you can click the mouse really fast and the shotgun just goes off as fast as you can click the mouse. Is there some kind of time delay I can put in after an onmousedown event? Or is there maybe a way to disable the mouseclick for a timeframe after an onmousedown event? Here is the code that I have now for the sound:
onMouseDown = function() {
shotgunSound = new Sound(this);
shotgunSound.attachSound("shotgun");
shotgunSound.start(0, 1);
}
Any help is greatly appreciated. Thanks.
View Replies !
View Related
Sound Play Delay
Hi all,
I am trying to develop my first flash app. The application emulates a "karaoke" service. It plays a background sound and at the same time records the sound coming from the mic. I use the "sound" class to play the sound (s.play() ) and the "netStream" class to record the mic sound (ns.publish("mysound", "record") ). In the same app, I then try to play these two sounds together. The problem is that I cannot synchronize them. My tests drove me to a conclusion which I am not certain for. The conclusion is that the method s.play() has a delay about 500ms until the sound starts playing. The result is that recording starts 500ms earlier than playback. When, then, I playback both of them the recording sound is 500ms after the backround sound. Is that delay for sure true? How can I overcome this problem?
thanks
View Replies !
View Related
Sound Delay In Firefox
I've got some sound objects that play when I click a button and they work fine when I run the SWF from Flash and in IE, but in firefox, there's a two second or so delay for the sounds. Any idea what might be causing this?
Code for the sound:
Code:
var sndMoo:Sound = new Sound(new URLRequest("sounds/Moo.mp3"));
sndMoo.play();
View Replies !
View Related
Best Way To Delay A Sound File
Hi,
I'm going to use a small Flash mp3 player to play a narration for each scene in a virtual tour and want to delay the mp3 file from downloading for 6-10 seconds so that we can prioritize image loading. What is the best way to do this?
The flash player is here.
The player is embedded like this:
<embed src="../music.swf?url=example.mp3&mode=play" width="22" height="20" autostart="True" wmode="transparent" quality="high" pluginspage="http://www.macromedia.com/go/getflashplayer" type="application/x-shockwave-flash"></embed>
Thanks!
View Replies !
View Related
Delay With Actionscript
im using a btn to call a the following function
function fadeOut() {
_root.onEnterFrame = function() {
squares._alpha -= 15;
if (squares._alpha<=0) {
_root.onEnterFrame = null;
}
};
}
But instead of happening right away, I want the code to delay a couple of seconds before the alpha starts to change.
Is there a way i can use AS to controll the time before an action executes?
View Replies !
View Related
Actionscript A Delay In This...
i cant seem to !!
i have a movie clip named hearts dynamically loaded to the stage and play according to the following actionscript: (c/o flashkit post - thanks)
Code:
kNbrHearts = 8;
kMinSpeed = 1;// minimum rise speed
kMaxSpeed = 20;// maximum rise speed
kMinSway = .0001; // minimum sway
kMaxSway = 1000; // maximum sway
kSwayAmplitude = 15;
kdistance = 10
kMin_y = 350
count=n
SW = Stage.width;
SH = 350;
moveHeart = function()
{
var a = this.phase + getTimer()*this.sway;
var sway = Math.sin(a);
//this._x += sway;
this._x += sway//*kDistance;
this._rotation = sway*kSwayAmplitude;
this._y -= this.speed;
if (this._y < -this._height) {
this._y = SH+this._height;
}
}
for (i = 1; i <= kNbrHearts; ++i)
{
var mc = _root.attachMovie('hearts', 'heart_' + i, i,
{_x:random(SW), _y:random(SH)});
mc._x = 365;
mc._y = 350;
mc.onEnterFrame = moveHeart;
mc._alpha = 25 + random(25);
mc.phase = Math.random()*2*Math.PI;
mc.speed = kMinSpeed + Math.random()*(kMaxSpeed - kMinSpeed);
//mc.sway = kMinSway + Math.random()*(kMaxSway - kMinSway);
mc.sway = kMinSway + Math.random()*(kdistance);
mc.gotoAndStop(random(3) + 1);
}
So the 'hearts' movie comes onto the stage and plays, lovely 8 )
What i am trying to create is a delay in its playing. So it plays, then stops, then plays, then stops... time of each delay can be the same, but i have no idea of the best, or even any way to do this... that'll work!
as its loaded to the root, i have tried unload, i have tried zeroing the alpha... and began to look at more complex solutions... but i'm getting very lost.
any thoughts very much apreciated.
thanks in advance
callum
View Replies !
View Related
[F8] Delay Using Actionscript
Is there any sort of command to just pause for a certain ammount of time? Such as if someone were talking...
_root.blablaba = "Hello!";
delay(5);
_rot.spblaaa = "My name is bob.";
So that people don't need to read an entire sentence in .2 seconds...
View Replies !
View Related
[F8] Delay Actionscript?
I have two frames, with a button on the first frame that links to the second.
On the first frame a mc fades in and stops. Then I have this code on the button (that links to second frame) so that the mc on frame 1 fades outa and goes to frame 2.
'ground' is the mc on frame one
Quote:
on(release){
_root.gotoAndPlay(2);
ground.onEnterFrame = function() {
ground._alpha -= 5;
if (ground._alpha <= 0) {
ground._visible = false;
delete ground.onEnterFrame;
}
}
}
Here though I want it too execute the fade code and once the alpha = 0 go to the 2nd frame. I kinda know the code but can't get it right?
TIA
View Replies !
View Related
Actionscript Delay
OK.
I need a function or some way to create a pause in between calls to a function and setInterval doesn't seem to be working.
Basically, I have several movie clips in the library named movie1, movie2, etc... Each contains a fading movie clip. I want to attach them all using actionscript, but i want to wait like 5 secs in between each one and i can't seem to get it to do that.
Here is the code i have so far without setInterval. It cause them all to appear on the screen at once.
var numOfEmployees = 4;
for (var i=1; i <= numOfEmployees; i++) {
var thisName = "movie" + i;
attachClip(thisName);
}
function attachClip(thisName){
thisMovie = _root.attachMovie(thisName, thisMovie + i, this.getNextHighestDepth())
thisMovie._x = 100;
thisMovie._y = (_root._height - thisMovie._height) - 100;
}
Now, this will make all movie clips appear on screen at the same time. What is the best way to create a 5 second delay between each call to attach clip? What is the proper way to use setInterval or is their a better way??
I need a solution that doesn't use the timeline at all, possibly just a function that would work like this...
for (var i=1; i <= numOfEmployees; i++) {
var thisName = "movie" + i;
attachClip(thisName);
wait(5);
}
Anyone know of a function like that? Thanks.
Anyhelp would be greatly appreciated.
View Replies !
View Related
Can You Delay Actionscript?
Can you delay actionscript so that it executes on a specific frame?
I have an animation and a button on the stage. I want the button to do something, but only when the animation gets to a certain point. So I've made the main timeline 60 frames long (my animation in embedded in a movie clip that loops every 60 frames) yet my actionscript is on frame 1.
If the button is pressed anywhere between frame 1 and 59 the animation jumps to the target of the button, whereas frame 60 of the first animation and frame 1 of the second (which the button links to) glide seamlessly. Can I write some code that will say something like...
"Do what I ask, but wait until frame 60 to do it"?
Cheers,
View Replies !
View Related
Can You Delay Actionscript?
Can you delay actionscript so that it executes on a specific frame?
I have an animation and a button on the stage. I want the button to do something, but only when the animation gets to a certain point. So I've made the main timeline 60 frames long (my animation in embedded in a movie clip that loops every 60 frames) yet my actionscript is on frame 1.
If the button is pressed anywhere between frame 1 and 59 the animation jumps to the target of the button, whereas frame 60 of the first animation and frame 1 of the second (which the button links to) glide seamlessly. Can I write some code that will say something like...
"Do what I ask, but wait until frame 60 to do it"?
Cheers,
View Replies !
View Related
Delay With ActionScript?
Hello. Was wondering if there's some AS that causes a layer to not run it actions for 30 frames. I have some AS in a seperate layer for a different animation that causes a transition, and would like some of the content on the page to run it's animation after the transition takes place...I hope that makes sense.
View Replies !
View Related
|