Tracking Forums, Newsgroups, Maling Lists
Home Scripts Tutorials Tracker Forums
  Advanced Search
  HOME    TRACKER    Flash




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.



FlashKit > Flash Help > Actionscript 3.0
Posted on: 11-12-2008, 03:37 AM


View Complete Forum Thread with Replies

See Related Forum Messages: Follow the Links Below to View Complete Thread

Playing Sound With Actionscript
Is there anyway to play a sound using actionscript without moving to a frame to play it?

[F8] Playing Sound Through Actionscript
I'm sure this is fairly easy, but how can I make a sound in the library play at the right exact time through actionscript? Say I want it to play 145 seconds after a certain frame. Any way how?

Playing Sound Using Actionscript
how do i start playing a sound using actionscript?
I want it to play when my _yscale property of a MC is below 30.
I have this code:

if (_yscale<30)
<code to start playing sound which i imported into library>


thanks

Playing A Sound With Actionscript
i found this tutorial, and everything works fine, but there's no mention there about how to stop the sound that's playing...

if anyone can help me with this it would be great...

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

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

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!

Locking Coll Mc With Mouse?
can somebody please tell me how can we make the mc which is locked with the mouse,like the one in http://www.djrummy.com/users/djrummy/one.swf , i tried making a mc and puting a frame action,truestartDrag ("mcNmae", true);
but it dosnt play like the one in cell-loc.I know their must be some actionscripting in it ,can somebody elaborate ??
thanx!

Ball Coll, Angles
Hi, I'm working with a ball that are going to bounce realistic.
But I can't make it realistic. What would the new angle be?

Take a look:

Sound Idea
would this work?


set up four buttons that are song choices.

then assign an action to them to stop all other sounds, and attach the background mp3 to the button.

each time they move between the buttons it kills the currently playing mp3 and plays the choice of that button.


is this right? does it take up too much in loading? it could be part of my preloader since it is in the main scene? also how can I make it so you can tell what choice you made?


thank you.

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

Need Idea For One-click Sound Control
I am planning on making a speaker button for my site, where on the first click the background music would stop and the icon would change to a certain shape, on the second click all sound effects will stop (mute all sound?), and button would change to another shape, and on final click everything will be back on again.

I am thinking about using a variable to keep track of the stage of the button, so like on each click do a +1 to the value, and if the var is over 2 then change the var back to 0. Do you think this will work? And I am thinking about putting the background music in it's own movieclip. Not too sure how to go about with the sounf fx on buttons and stuff though...

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

I Nead An Idea For An Actionscript
i nead an idea for an actionscript. i have made many recent actionscripts such as flashremote. e-mail blizard404@aol.com if you want a creation or to ask me a question.

How Would I Translate This Idea In To Actionscript?
This is for an movie clip animation that's got to step on an interval...

int(tween(time, 0, 10, easeout)) * 10;

I don't know enough AS syntax!!!

Inserting Adsense In ActionScript. Any Idea?
Hii fellow members,

Can anyone tell me that how can I achieve this, like how can I insert Adsense script into ActionScript?

Had anyone tried it yet?

Thanks,
Manu.

Any Idea How To Pause Sound.load()? Or At Least Decrease The Speed?
Hi,
I need to pause the sound loading in order to be able to resume the download. It could work even if manually decrease the speed of downloading the sound file.
Thank you

Hey My New Games Idea's Actionscript Doesnt Work
i have the code

onClipEvent (load) {
count = 0;
}
onClipEvent (enterFrame) {
if (Key.isDown(1)) {
this.attachMovie("spark", "hit"+hitNum, 1);
hitNum++;
}
if (Key.isDown(2)) {
this.attachMovie("spark"+hitnum, "hit2", 1);
hitNum++;
}
if (hitNum>3) {
hitNum = 0;
}
}

but it only lets me shoot one then restarts. how do you make it so you can shoot 3 before it restarts? its a harry potter platform shooter!

check out the fla.

Control Tint Via Actionscript, Any Idea How To Achieve This?
Hi all,

does anyone know how to set the TINT not the colour of an object using actionscript.

I can set the alpha no problem, i.e


ActionScript Code:
function over() {    this._alpha = 100;}function out() {    this._alpha = 70;}


But is there a way in achiving a tint instead of an alpha?

Cheers

Trev

Hey My New Game Idea's Actionscript Doesnt Work
i have the code
onClipEvent (load) {
count = 0;
}
onClipEvent (enterFrame) {
if (Key.isDown(1)) {
this.attachMovie("spark", "hit"+hitNum, 1);
hitNum++;
}
if (Key.isDown(2)) {
this.attachMovie("spark"+hitnum, "hit2", 1);
hitNum++;
}
if (hitNum>3) {
hitNum = 0;
}
}
but it only lets me shoot one then restarts. how do you make it so you can shoot 3 before it restarts? its a harry potter platform shooter!
check out the fla.

Helping Translating Idea From Java To Actionscript
I was trying to do the following code in actionscript but I failed to make it success:

PHP Code:





public class stringChars{
    int anime_x = 75;
    int x = anime_x;
    public stringChars(){
        if(x == anime_x){
            do{
                x++;
                System.out.println("x = "+x+ " and animex = "+anime_x);
                if(x > 450){
                    x = anime_x;
                    continue;
                }
            }while(x<455);
        }
    }
    public static void main(String[] args){
        stringChars more = new stringChars();
    }








well imagine that x = this._x
amd there's no System.out.println operation
by the yes it works it prints a loop of number between (75,455)[if u dont know that it means that it doesn't include 75 or 455 like {x|75 < x < 455}]

hope u can help me I'm a bit lost ^^;

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

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

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

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

°°°keep The Sound From Playing If It Is Already Playing
Hi FlasherZ,

I add this code to my buttons but it didn't work - can you fix it. Do I have to define a variable "playing" in the first frame???

I read this tutorial, chapter "How to Start, Stop and Loop a Sound Object" and everything works fine but if I hit the on button I hear 2 sounds playing, if I hit the button again, I hear 3 sounds playing at the same time - U know what I mean, so I wanted to use the code in the tutorial with the variable "playing".

Here is the link to the tutorial:
http://www.kennybellew.com

I would appreciate some advices.

Omitofo-
Attila

Playing Out QT With Sound
Does anybody know if there is a way to play a QT with sound direct from Flash. I have a video that needs to sync exactly.
The playout is via hard drive/CD-ROM not the web. I was wondering if you can make a pop-up window that will execute the file?.
I'm Stumped!

Playing With Sound
I have 4 faders on a screen. each fader has a start and stop button. using the normal action script I can get 4 different files to play. PROBLEM the stop button on each fader will stop the music for any song even thought it is assigned to another, and any fader will change the music for any song. how do I get the fader to only control the song it is assigned to and to get the stop button to stop on the song it is assigned to? Thanks in advance

Playing A Sound?
hello,
im really stuck here, i'm designing a "phone/keypad" style navigation and i have used actionscript to make the user dial a certain extension, which is displayed in a box, to get to a certain page, and if they type in a wrong code, the box resets itself. BUT, i want to have a sound to play if the user enters a wrong code. the code i have used is below, PLEASE HELP.

on (release) {
switch (password) {
case "121" :
gotoAndPlay("contact", 1);
break;
case "122" :
gotoAndPlay("about", 1);
break;
default :
password = "";


I look foward to all your replies! i got a feeling this is gonna be easy, but i just cant see the wood for the trees!

Thanks
Yoda

Sound Not Playing
Hi-
I have a movie with three sounds: wind, rain and thunder. The rain is a movie clip with the sound embedded. The wind is just a sound on the main timeline. The lightning is a graphic with a keyframed thunder sound on the main timeline so they are both in sync. All sounds begin with "Event".

For whatever reason, the thunder does not play, even with a preloader. How would you best handle this?

I moved the thunder sound into the lightning movei clip and it seems to work fine. Why wouldn't it in the main timeline? Too many sounds?

Also, with the lightning clip, should the thunder sound be "stream" or "event". Help!! How would you best handle these sounds?

Thanks!!

-Rob

Sound Not Playing.
I created a sound movie with an mp3 file. The movie has a volume slider included in it. The file is named "bgsound.swf". I created this movie with this script:

s = new Sound();
s.attachSound("backsound");
s.start("0", 3);

When I test this movie, everything works fine.

My problem is when I load it into another movie, I can see "bgsound.swf" graphics, but I no longer have any sound. I loaded "bgsound.swf" onto the other movie trying each of these scripts:

loadMovieNum ("bgsound.swf", 1, "POST");
loadMovieNum ("bgmusic.swf", 1, "GET");
loadMovieNum ("bgmusic.swf", 1);

None of them worked. HELP!

I am using Flash MX.

Sound Not Playing HELP
i'm working on a flash site where i call an mp3 file using this script:

mySound = new Sound(this);
mySound.loadSound("http://..sample2.mp3", true);
mySound.start(0, 999);

this file works it is 256k i then change it to the song file which is 3.2mb and it won't play at all ... is it because of the size ?? anyway i can play this 3.2mb mp3 dynamically ???

Sound Playing
how can you make a sound play with actionscript withought going to another frame?

Playing Sound
Still new with actionscript...

I'm having trouble with this script:

song = new Sound();
song.attachSound("main_music");
_root.song.start(0, 99999);
if (_root.song.start(0, 99999) == true) {
a = 1;
} else if (_root.song.stop == true) {
a = 2;
}
song.setVolume(50);
if (a=2) {
_root.playButton.onRelease = function() {
song.start(0, 99999);
};
}
_root.stopButton.onRelease = function() {
song.stop();
a = 2;
};

I want the play button to be inactive when the music runs, preventing the music to start over and over again with every push of playButton.

One more thing, can I use some actionscript efect for the song, something like fadein in the begining of the song.

Please help!!!

Playing Sound
Hi,

I am searching for solution in one to you experienced flashers probably simple thing. But I must admit that I have not yet found answer to this and I have hope to got one in this forum, at least some guidelines

I am designing web page that must play mp3 sound. It is a sound file: for example called default.mp3 . I have stop/play button, and when the page is loaded, default.mp3 starts. I can click button and then sound stops, and button changes to "play" and pressing it again will play that mp3 again. I done this with some JavaScripting and EMBED tag, whic is calling default mp3 player to play this file.

But problem is, not all people have mp3 player. Those on win98 do not have it preinstalled.

So i thought about possibility to get done this action that I described in flash. I already have some flash animation on that page
so another one would not be a problem but, I do not know if flash
can play some default.mp3 file without bundling, importing etc.

Is there some way to create such small application in flash that will somehow import default.mp3 on the fly. I know, I can complie this file into flash first and play it, but I would like to make it so, that with only by changing the default.mp3 file (I just need to overwrite it with new sound) new music is played.

Is there any chance that this can be done!
Please help if you understand this little desperate posting of mine :<

Regards,

Nenad

Sound Is Not Playing ?
peepz why is my sound not playing ?

if i play it in the loop1.swf it plays (if i remove the stop out of the first frame) but if i load the loop1.swf in my main.swf it wont play !?!

code main.swf:

frame1//////

Code:
_root.mcBG.mcRadio.mcRadioLoader.mcSoundContainer.loadMovie("sounds/loop1.swf")
frame2//////
stop();
+
a perloader with a good script (placed in a MC)

frame3//////

Code:
stop();
trace("frame 3");
_root.mcBG.mcRadio.mcRadioLoader.mcSoundContainer.gotoAndPlay(2);
the loop1.swf code:

frame1///////

Code:
stop();
frame2///////

Code:
loop1 = new Sound();
loop1.attachSound("loop1");
loop1.start(0, 99999);
loop1.setVolume(20);
frame3///////

Code:
loop1.setVolume(loop1.getVolume()+1);
frame4////////

Code:
if (loop1.getVolume()>100) {
stop();
} else {
gotoAndPlay(3);
}
maybe it have something to do with export in first frame ?

the weirdness is that it plays if its tested in loop1.swf and it doesn't play in de main.swf

who can help?

thnx for everything!!!!!

Playing Sound MC's At Once
I think I posted this is the wrong section. This is probably more of an actionscript question.

We are building a musical flash site for a group project. We have many different sound clips that we want a user to be able to mix and match. Each sound clip is associated with a MC. When they click a sound, I want it to load into an empty MC. I can get the first sound to play just fine. When I try to load in the second sound into the second empty MC, it automatically stops the sound of the first MC and then will play the sound of the second MC. I want the sound of MC1 and MC2 to play simultaneously. Is this possible? I'm not even sure where to begin after that. Is there anybody with some ideas? Thanks

Playing A Sound Mc
I want to start playing a sound mc.. or a sound whatever when i press a button.. and i want to be able to stop the sound with by pressing the same button.. how can i do that.. okay so i can't attack the.fla file cause its bigger than 2 MB.. so if someone could just easily explain me.. where to put the sound file.. and how to play it and stop it with the touch of a button.. that would be awesome... any help is appreciated.. thanks!

Sound Not Playing
I downloaded a nice christmas flash program from flash kit, everything works fine but the sound isn't working.

I am using flash MX2004

any ideas what i need to do to get the sound to play?

Thanks

[MX] Sound Playing
how do i code for, it to see if a sound is already playing??

Sound Not Playing
Pretty simple problem here....though I don't know what's wrong.
All I need to do is play a simple sound effect. For testing purposes I had it play at the press of a button:

Code:
var in_alert3:Sound = new Sound(new URLRequest("sounds/alert3.wav"));
snd_btn.addEventListener(MouseEvent.CLICK, snd_btnFunction);
function snd_btnFunction(event: MouseEvent) {
if(chat_in.text == "time")
{
in_alert3.play();
}
}

Nothing happens...no sound effect is played. I know the button event works just fine as well.
Any ideas? Thanks in advance.

Some Sound Not Playing?
I have a flash file that someone else created. It has music and narration.
When previewing movie on local machine, everything thing works fine. On a web server, the narration does not play (or at least we can't hear it).
I am wondering if the problem is this little bit of code in the html page that plays the movie? Our servers are LAMP, and as far as I know, do not run vb script. Is that the problem?

Thanks in advance!

Here is the code I am wondering about:


Code:
<script language="VBScript" type="text/vbscript">
<!-- // Visual basic helper required to detect Flash Player ActiveX control version information
Function VBGetSwfVer(i)
on error resume next
Dim swControl, swVersion
swVersion = 0

set swControl = CreateObject("ShockwaveFlash.ShockwaveFlash." + CStr(i))
if (IsObject(swControl)) then
swVersion = swControl.GetVariable("$version")
end if
VBGetSwfVer = swVersion
End Function
// -->
</script>
as code:


Code:
stop();

// [ XML HANDLING ] \


var x:XML = new XML();
x.ignoreWhite = true;

var urls:Array = new Array();
var captions:Array = new Array();
var whichSlide:Number;

x.onLoad = function(success) {
var swfSlides:Array = this.firstChild.childNodes;
for(i=0;i<swfSlides.length;i++) {
urls.push(swfSlides[i].attributes.url);
captions.push(swfSlides[i].attributes.caption);
}
holder.loadMovie(urls[0]);
whichSlide = 0;
}

x.load("module1.xml");

// ================================================[ /XML HANDLING ] ======================================== \

// ================================================[ AUDIO CONTROLS ] ======================================== \

var myNumber:Number = 1;
var musicFolderName:String = "voiceover/";
var soundDLDuration:Number;
var curPlaybackPos:Number;
var curTrackNum:Number = 0;
var mySound:Sound;
var curTrackVolume:Number = 85;


this.volumePercentText.autoSize = "left";
this.volumePercentText._visible = true;

function playMusicFunc() {

mySound = new Sound();

mySound.onSoundComplete = function() {
if (curTrackNum == (myLV.totalTracks - 1)) {
curTrackNum = 0;
playMusicFunc();
mySound.loadSound((musicFolderName + "slide-" + curTrackNum + ".mp3"), true);
} else {
curTrackNum++;
playMusicFunc();
mySound.loadSound((musicFolderName + "slide-" + curTrackNum + ".mp3"), true);
}
curPlaybackPos = 0;
if(whichSlide < urls.length-1) {
whichSlide++;
holder.loadMovie(urls[whichSlide]);
}
}


mySound.setVolume(curTrackVolume);
volumeControl.volumeMask._width = curTrackVolume/2;




if (curTrackNum < (myLV.totalTracks - 1)) {
nextTrack.enabled = true;
nextTrack._alpha = 100;
} else if (curTrackNum == (myLV.totalTracks - 1)){
nextTrack.enabled = false;
nextTrack._alpha = 50;
nextTrack.gotoAndStop(1);
}

if (curTrackNum == 0) {
prevTrack.enabled = false;
prevTrack._alpha = 50;
prevTrack.gotoAndStop(1);
} else if (curTrackNum > 0){
prevTrack.enabled = true;
prevTrack._alpha = 100;
}

disablePlay();
mySound.loadSound((musicFolderName + "slide-" + curTrackNum + ".mp3"), true);

}


var myLV:LoadVars = new LoadVars();
myLV.load("total_tracks.txt");
myLV.onLoad = function(success) {
if (success) {
playMusicFunc();
}
}


_root.onEnterFrame = function() {
var soundLoaded:Number = mySound.getBytesLoaded();
var soundTotal:Number = mySound.getBytesTotal();
var soundDLPercent:Number = Math.round((soundLoaded / soundTotal) * 100);

progressBar.barTOP._width = Math.round((soundLoaded / soundTotal) * 100);

soundDLDuration = Math.round((mySound.duration / soundDLPercent) * 100);
progressBar.playbackProgSlider._x = (Math.round((mySound.position/soundDLDuration) * 100)) - 5;
progressBar.playbackBarMask._width = (Math.round((mySound.position/soundDLDuration) * 100));

var7.text = "soundDLDuration : " + (soundDLDuration/1000);

if ((mySound.position + 10) > soundDLDuration && (mySound.position - 10) < soundDLDuration) {
delete _root.onEnterFrame;
}
}

this.progressBar.barTOP.onPress = function() {
progressBar.barTOP.onEnterFrame = function() {
if (_root._xmouse >= progressBar._x && _root._xmouse <= (progressBar._x + progressBar.barTOP._width)) {
var soundGoTo:Number = Math.round(_root._xmouse - progressBar._x);
mySound.start(((soundDLDuration/1000)*(soundGoTo/100)));
disablePause();
}
}
}

this.progressBar.barTOP.onRelease = function() {
delete progressBar.barTOP.onEnterFrame;
disablePlay();
}

this.progressBar.barTOP.onReleaseOutside = function() {
delete progressBar.barTOP.onEnterFrame;
disablePlay();
}

// --------------[play/pause]--------------- \

function disablePlay() {
playMusic.enabled = false;
playMusic._alpha = 50;
playMusic.gotoAndStop(1);
pauseMusic.enabled = true;
pauseMusic._alpha = 100;

}

function disablePause() {
playMusic.enabled = true;
playMusic._alpha = 100;
pauseMusic.enabled = false;
pauseMusic._alpha = 50;
pauseMusic.gotoAndStop(1);
}


this.playMusic.onRollOver = function() {
this.nextFrame();
}

this.playMusic.onRollOut = function() {
this.prevFrame();
}

this.playMusic.onRelease = function() {
mySound.start((curPlaybackPos/1000), 9999);
disablePlay();
bgMusic.start();
}

this.pauseMusic.onRollOver = function() {
this.nextFrame();
}

this.pauseMusic.onRollOut = function() {
this.prevFrame();
}

this.pauseMusic.onRelease = function() {
curPlaybackPos = mySound.position;
mySound.stop();
disablePause();
bgMusic.stop();
}
// --------------[/play/pause]--------------- \

this.nextTrack.onRollOver = function() {
this.nextFrame();
}

this.nextTrack.onRollOut = function() {
this.prevFrame();
}

this.nextTrack.onRelease = function() {
if (curTrackNum < (myLV.totalTracks - 1)) {
curTrackNum++;
playMusicFunc();
}

if(whichSlide < urls.length-1) {
whichSlide++;
holder.loadMovie(urls[whichSlide]);
}
}

this.prevTrack.onRollOver = function() {
this.nextFrame();
}

this.prevTrack.onRollOut = function() {
this.prevFrame();
}

this.prevTrack.onRelease = function() {
if (curTrackNum >= 1) {
curTrackNum--;
playMusicFunc();
}
if(whichSlide > 0) {
whichSlide--;
holder.loadMovie(urls[whichSlide]);
}
}

// --------------[volume control]--------------- \
this.volumeControl.onPress = function() {
this.onEnterFrame = function() {
if (_root._xmouse >= volumeControl._x && _root._xmouse <= (volumeControl._x + volumeControl._width)) {
curTrackVolume = (Math.round(_root._xmouse - volumeControl._x)) * 2;
volumeControl.volumeMask._width = (curTrackVolume / 2);
mySound.setVolume(curTrackVolume);
volumePercentText.text = (curTrackVolume + "%");
volumePercentText._visible = true;
}
}
}

this.volumeControl.onRelease = function() {
delete volumeControl.onEnterFrame;
volumePercentText._visible = true;
}

this.volumeControl.onReleaseOutside = function() {
delete volumeControl.onEnterFrame;
volumePercentText._visible = true;
}
// --------------[/volume control]--------------- \

// ================================================[ AUDIO CONTROLS ] ======================================== \


// ================================================[ UI CONTROLS ] ======================================== \

var tipInt;
tooltip._visible = false;
var count = 0;

function showTip(tiptext) {
if(count == 5) {
clearInterval(tipInt);
count = 0;
tooltip.tiptext.text = tiptext;
tooltip._x = _root._xmouse-20;
tooltip._y = _root._ymouse;
tooltip._visible = true;
_root.onMouseMove = function() {
tooltip._x = _root._xmouse-20;
tooltip._y = _root._ymouse;
updateAfterEvent();
}
}

else {
count++;
}
}

function hideTip() {
clearInterval(tipInt);
tooltip._visible = false;
delete _root.onMouseMove;
}

link_mc.onRelease = function():Void {
this.getURL("http://www.libraries.uc.edu", "_blank");
curPlaybackPos = mySound.position;
mySound.stop();
bgMusic.stop();
disablePause();

}

link_mc.onRollOver = function():Void {
this.gotoAndPlay(2);
tipInt = setInterval(showTip,100,"www.libraries.uc.edu");
}

link_mc.onRollOut = function():Void {
this.gotoAndPlay(5);
hideTip();
}


mailLink_mc.onRelease = function():Void {
this.getURL("http://www.libraries.uc.edu/information/contact/index.html", "_blank");
curPlaybackPos = mySound.position;
mySound.stop();
bgMusic.stop();
disablePause();
}

mailLink_mc.onRollOver = function():Void {
this.gotoAndPlay(2);
tipInt = setInterval(showTip,100,"Find answers here");
}

mailLink_mc.onRollOut = function():Void {
this.gotoAndPlay(5);
hideTip();
}

credLink_mc.onRelease = function():Void {
_root.opaqueBackground = true;
attachMovie("credits_mc", "credits_mcee", 1);
credits_mcee._x = 0;
credits_mcee._y = 0;
credits_mcee.closeButton_mc.onRelease = function():Void {
this._parent.removeMovieClip();
curPlaybackPos = mySound.position;
mySound.stop();
disablePause();
};
curPlaybackPos = mySound.position = bgMusic.position;
mySound.stop();
bgMusic.stop();
disablePause();
creditWindow.mcCloseSquare.onRelease = function():Void {
this._parent.removeMovieClip();
}
}

credLink_mc.onRollOver = function():Void {
this.gotoAndPlay(2);
tipInt = setInterval(showTip,100,"Meet the contributors");
}

credLink_mc.onRollOut = function():Void {
this.gotoAndPlay(5);
hideTip();
}
// ============ bg SOUND ============= \
var bgMusic:Sound = new Sound();

bgMusic.loadSound("BGMUSICnew.mp3", true);
bgMusic.start(0, 9999);

var mySoundVolume:Number = 15;
bgMusic.setVolume(mySoundVolume);

musicOff.onRelease = function():Void {
bgMusic.stop();
}
musicOn.onRelease = function():Void {
bgMusic.start();

}

Playing More Than One Sound?
Is there a way to play more than one sound at the same time? I have, for example, a thunderstorm scene that has a wind wav and also a thunder wav that's triggered each time the lightening flashes. Also, each of my nav buttons plays a different sound onRollOver. Right now, I'm doing all of my sounds programmatically. I can get the wind and the thunder to play at the same time, but then if my mouse happens to roll over a nav button, the storm noises stop. Is there a way to fix this?

If Sound Playing()....?
how can I tell if a sound if playing or stopped?

I have a simple music player that just plays the client jingle when the movie loads. It has a play and a stop button, and a piece of dynamic text that changes to "Music Off" if the user hits the stop button, and it changes back to "Music On" if they hit the play button.

However, if the user just lets the jingle play in it's entirety, the dynamic text still says "Music On" when the jingle is done.

How can I make that change when the music stops?

Here's what i've tried, but it does nothing (it doesn't give me an error, but it doesn't do anything either...)


ActionScript Code:
if (jingle.playing = true)
{
this.musicPlayer_mc.musicTxt.text = "Music On";
}
else
{
this.musicPlayer_mc.musicTxt.text = "Music Off";
}

Again, that doesn't seem to do anything...the code validates and I get no errors when the movie runs, but nothing happens when the jingle stops playing....

Sound Keeps Playing...
when i exit the frame that is playing my video (flv) the sound keeps playing

is there a proper way to ensure the music stops when the video does?

Is This Possible? About Playing Sound.
I have millions of small mp3 files. And I'd like to import every 100 files into a flash file, and then play one of it per the request from javascript. The swf will be used in a webpage.

Since there are millions of mp3 files, I can't use mouse to click and select them then export the symbol of these files.

I need a batch mode, or a script mode. Which actionscript APIs can I use to import mp3 and export them to actionscript from library? And at last, I need compile the .fla files to .swf files.

Any suggestions? Help me please.

Sound Is Not Playing ?
peepz why is my sound not playing ?

if i play it in the loop1.swf it plays (if i remove the stop out of the first frame) but if i load the loop1.swf in my main.swf it wont play !?!

code main.swf:

frame1//////

Code:
_root.mcBG.mcRadio.mcRadioLoader.mcSoundContainer.loadMovie("sounds/loop1.swf")
frame2//////
stop();
+
a perloader with a good script (placed in a MC)

frame3//////

Code:
stop();
trace("frame 3");
_root.mcBG.mcRadio.mcRadioLoader.mcSoundContainer.gotoAndPlay(2);
the loop1.swf code:

frame1///////

Code:
stop();
frame2///////

Code:
loop1 = new Sound();
loop1.attachSound("loop1");
loop1.start(0, 99999);
loop1.setVolume(20);
frame3///////

Code:
loop1.setVolume(loop1.getVolume()+1);
frame4////////

Code:
if (loop1.getVolume()>100) {
stop();
} else {
gotoAndPlay(3);
}
maybe it have something to do with export in first frame ?

the weirdness is that it plays if its tested in loop1.swf and it doesn't play in de main.swf

who can help?

thnx for everything!!!!!

Playing A Sound
I have a short 3 second mp3 that I want to play as soon as my navbar swf loads. Right now I have a typical 2 frame preloader that loads everything then begins the nav animation on frame 3. I want the mp3 to begin playing on frame 3 as well. How exactly do I go about doing this?

On a side note, the mp3 I made is compressed at 128 kbps, and the file size is 60 kb. Is this too big? Should I have condensed it down to 80 or 56 kbps? The total file size of my Flash nav animation is 86 kb, and it's also about 3 seconds long. I want it to load pretty fast considering it's a nav bar, if anyone has any experience with this and wants to chime in, let me know, thanks!

Sound Keep Playing
I have a movie clip for the intro that has two movie clips inside and plays a sound for the intro. Then the movie clips react to the mouse like buttons and have sound but the intro part does not repeat.

Here's the problem: The sounds play as if the movie clip is playing and the sounds repeat regularly, but the action that the sound is attached to doesn't change.

I have Adobe CS3 Flash 9, actionscript 3 and have tried syncs of event, stream, start - repeat 1 and 0.

Thanks

Copyright © 2005-08 www.BigResource.com, All rights reserved