Variable To Play Sound
Post Preview: On the mainstage my intro animation takes place in one frame. all the objects go onto the screen via actionscript. Im am trying to sync a small sound when several movieclips reach their final destination point. Is it possible to play a sound or play a clip/w/sound using a variable, for instance, movieclipApos = _root.movieClipA._x if (movieclipApos = 100){ _root.soundclip.gotoAndPlay("sound start"); }
or something of that nature.
thanx for your help.
FlashKit > Flash Help > Flash MX
Posted on: 07-11-2002, 12:02 AM
View Complete Forum Thread with Replies
See Related Forum Messages: Follow the Links Below to View Complete Thread
Variable To Play Sound
On the mainstage my intro animation takes place in one frame. all the objects go onto the screen via actionscript. Im am trying to sync a small sound
when several movieclips reach their final destination
point. Is it possible to play a sound or play a clip/w/sound using a variable, for instance,
movieclipApos = _root.movieClipA._x
if (movieclipApos = 100){
_root.soundclip.gotoAndPlay("sound start");
}
or something of that nature.
thanx for your help.
Making One Button Play One Sound And Another Play A Different Sound
i'm very much a novice when it comes to flash.
i've created three separate buttons in three separate layers. i've also added three music files in three more layers. how can i get it so one button plays one music file and another button plays a different music file? i've tried putting "goto and play" for each button in actionscript but it doesn't seem to help.
any ideas?
i would be very grateful
Attach Sound, Play Sound & Stop Sound.
Hey there,
I was wondering if any of you could help me please.
I want to play a song which I have named "rundmc" The file extension is ".mp3"
I want a button to play this mp3 which I read you need to attach that sound, then play it and I want to a button to stop that sound, or preferably the play button to change into a stop button.
I've read the help files, but none of it works and I've changed the linkage for the mp3 to export for action script, but nothing works!!!
Please help,
NK.
How To Play A Sound For 6 Times With Set Play Interval?
Hi,
I know how to play a sound effect:
Quote:
var mySoundReq:URLRequest = new URLRequest("laser.mp3");
var mySound:Sound = new Sound();
mySound.load(mySoundReq);
mySound.addEventListener(Event.COMPLETE, playSong);
function playSong(event:Event):void {
mySound.play();
}
The above sound effect play only one time. Actually I wish to play the sound effect for 6 times and at a set play interval (e.g. play the sound effect, wait 2 seconds, play again, wait another 2 seconds......). How can I do that?
I am thinking to use a Timer object. However I have no idea how to link with the playSong function.
Thanks and best regards
Alex
On Press Play Sound On Release Stop Sound
I have a button that is inside a movie clip 'forward'.
When you press the button it plays another movie clip 'time' forwards
on (press) {
forward = "1";
}
on (release, rollOut, dragOut) {
forward = "0";
}
on the button and:
if (forward eq "1") {
tellTarget ("/time") {
nextFrame();
}
}
on the first frame of the 'forward' movie
I would like sound to happen when you press the button and stop when you realease the button
but I not sure how any help would be gratefully excepted
Sound Overlap When 2 Swf Play Sound At The Same Time P R O B L E M
Figure this:
I sen to my clients via mail an regular html with a swf embebed. They recibe the html and the flash starts playing the loop sound. Therere are, also the loop, severals sound trigered in different parts of the swf file.
the problem starts when my clients double click in the outlook inbox and the html pops up and there we have 2 html with 2 swf playing sound at the same time.
I tried stop all sounds at the begining of the movie. but it only stops the loop sound but not the trigered sounds of the rest of the time line.
is there a way to stop the sound of the first swf when the second pop up?
anyone?
Dont Play Sound Until Another Sound Finished
Hi guys
How do i wait until a sound has stopped playing before playing another sound. Ideally something along the lines of :
if (sound1.hasCompletedPlaying()) {
sound2.start();
}
im not sure what the boolean check is for if a sound is still playing or not though.
thanks in advance.
Play Sound/stop Sound Button
i want to make a single button to play a sound, and if pressed again, stop the sound. and if pressed again, play the sound, and so on...
i know it has to be made with a boolean variable, true/false, but i just can't figure out how.
any help?
thank you very much.
How To Use A Value Of A String Variable As A Sound Class (as Linkage Name Of A Sound File)?
Hi,
I need to use the value of a string variable as a linkage name of the sound imported in the library, I have this code:
var SoundArray:Array=new Array;
SoundArray[0]="S1";
SoundArray[1]="S2";
SoundArray[2]="S3";
var MySound = new SoundArray[0];
B1.addEventListener(MouseEvent.CLICK,PlaySound);
function PlaySound(event:MouseEvent) {
MySound.play(0,0);
}
where S1,S2,S3 is the name of the classes in the linkage name for the 3 sound files in the library.
I get this Error for the highlighted line of code:
TypeError: Error #1007: Instantiation attempted on a non-constructor.
at Untitled_fla::MainTimeline/frame1()
PLAY Sound And STOP Sound
I have no clue how to play and stop sound. I tried everything but I guess I am doing it wrong!
basically...... the name of the clip i want to play is
sound1
i have a little play button and a little stop button
i need the code so that it will play sound1 when clicked on
and the stop button i just put stop all sounds so i guess that should take care of it..but if that is wrong then please let me know, lol
thanks
xox marqi
Play Sound#2 On Complete Of Sound#1?
I'm a total newbie when it comes to action scripting and I'm hoping someone can help me out.
I need a script that plays sound#1 and when sound#1 is over plays sound#2. Seems simple but I've been trying to figure it out without any luck.
The sound files are background music that play over a multi scene project so keyframing is not really an option.
Thanks
Andy Hunter
Sound Switch (on/off) To Play A Sound.
Hi there!
I am a begginer, and I would like to solve this:
There are 2 switches,(each one has "on" and "off" position)
But, only play the sound when the switch#1 is "on" and the switch#2 is also "on".For example if the Switch#1 is "off" and switch#2 is "on"
nothing happens, that is it!
Thanks!
Ricardo
Variable Play - How?
OK Im going beserk with this .....what am i doing wrong..
BTW Using Flash MX.
Basically trying to randomly play files on the main timeline.
Im giving the code here:
On one MC :
onClipEvent (enterFrame) {
n=random(5);
_root.mpx="_root.cell"+n;
}
And on another Button:
on (release) {
_root.mpx.play();
trace(_root.mpx);
}
SO whats wrong??
Ns.play (variable Instead Of URL)
Hi,
I'm a bit of a flash noob, but after completing Lee's tutorials alongwith others i've found online, I'm beginning to get the hang of both video integration and 'light' actionscript and am creating my own FLV Hub, as it were, with buttons that trigger an ns.play("url") which switches the currently playing FLV in my display.
My question is this:
Rather than attaching individual ns.play commands to each of these buttons, (there's a lot!) i would like to dynamically assign the FLV via the instance name of each button..
For example if I had say, 3 btns and labelled them each vid1, vid2, vid3.. and had a 3 flvs called 1.flv, 2.flv, 3.flv, then i could write some code such as:
Code:
theButton=_root.menu["vid"+i]
//variable to store the button number
theButton.thisNum=i;
theButton.onEnterFrame() {
_root.menu["vid"+this.thisNum].onRelease = function() {
ns.play(thisNum+".flv");
}}
Would this work? can i pass variables to the URL parameter of .play?
If not, how would you advise going about it?
All your advise and help are greatly appreciated,
Long live Lee + gotoandlearn! :D
Goto And Play (variable Name)?
Hi there,
I have some code that I need some input on.
A variable is set with a value.
This value is the name of the frame that I want the movie to goto and play.
How do I get the go to and paly command play the frame tat is in the vairable
Goto and play frame lable (variable)?
I have tried a few different ways such as setting the properties to Lable and Expression. I have tried the eval command as well as many combinations of brackets and quotes.
Any ideas?
Thanks, Mike
MX - Play() Action With Variable? Please Help
Hi.
Could someone please tell me if there is a way to use a variable in the play()/stop() action. e.g. I'm trying to stop whatever movie is playing.
deck = "_level" add (whichmovie)
_root.deck.stop()
Thanks in advance.
Deck
Play Depends On Variable?
Ok, here is my problem. I am sponsoring someone with a flash intro.
Now, if the sponsorship dies, i do not want them to still be able to use my intro. Is it possible to insert some actions script that would first look for a variable somewhere on the onternet, and if it is there.. it plays?
I was thinking if on my hosting i created a text file called "sponsor.txt" and in it would say "sponsor=true"
Could i put some sort of: If blah blah blah sponsors=true, goto and play next scene?
else if: stop ??
If this is possible how would I do it?
Thanks very much guys
Dion
How To Get GotoAndPlay To Play A Variable?
Hi,
I have asked this question before but haven't got an answer that gets it working.
i have set a variable up called playin.
I want the gotoAndPlay command to play that frame label it contains. I have tried gotoAndPlay(playin); doesn't work. I have tried changing it contents to be the frame number still doesn't work.
the variables contents is set inside a button (which is a movie clip).
does that have an impact on it?
any help would be great.
Use Variable To Run Goto And Play
I have a variable called 'randomclap' which is used to randomly choose a movie clip. This works fine, however I do not know how to tell it to play. Right now I am using this which is'nt working
_root.randomclap.gotoAndPlay("clap");
Any Ideas?
Goto And Play Variable Set
I am trying to set the 'goto and play' function so that it will go back and start from frame 1 a set number of times before continuing to the next frame. How do I do this?
Play Timeline Until Variable Changes - How To?
What I'm trying to do is this:
I have a movie clip that on mouse over play the frames "show" and in roll out play the frames "hide"
But I want the movie to play "show" until the variable name "menuPlaying" changes.
main time line:
Code:
menuPlaying = 0;
stop();
Stage:
Code:
on(rollOver) {
_root.menuPlatform.gotoAndPlay("show");
}
on(rollOut) {
_root.menuPlatform.gotoAndPlay("hide");
}
Inside menuPlatform movie clip I have the animations labeled "show" and hide"
I only have 1 frame in the main timeline.
Passing A Variable Via URL To Play A FLV
This seems like it should be rather simple but I am having troubles figuring it out.
I want to create a link to an HTML page something like this :
MyMoviePage.html?theFile=MyMovie.flv
In the HTML page is a SWF file that takes the "theFile" variable and plays that FLV.
Actionscript :
flvPlayback.contentpath = theFile;
Do I need to use FlashVars and or Javascript?
I can't get the code in the SWF to read the theFile variable.
Any help would be greatly appreciated.
Mark
Load ColdFusion Variable To Play A Certain MC?
is there a way to Load a ColdFusion Variable into a Flash file to do a TellTarget on a MC, or to invoke an action to play a particular MC at a certain Frame??
thanks a lot guys,
relmone.com
:P
Goto And Play Frame=Variable
Hello.
I am trying to set a command where tell Target is telling a movie clip to goto and play a certain frame. However the frame number is defined by a variable elsewhere in the Movie.
Is this done using the "expression" option - if so how?
Thanks for any help possible
BTW - I'm using Flash 5 if that makes any difference!?
Thanks,
Pete
Play Only If Variable==true Problem...
Dear fellow Flashers,
I'm trying to command flash, with a button on another level, to only play a keyframe, labeled "start_here" if it is at a certain keyframe, which has the variable "already_played" assigned to it as an action.
I would actually like this variable to cover a whole section of the movie, and I have 2 keyframes with this action, one at the begining and one at the end of this section, and I believe that the variable is applied to this whole section.
I tried using the following code below, but the movie plays at "start_here" regardless of wheather it is at the variable or not.
on (release) {
if (_level1.already_played == true) {
_level1.gotoAndPlay('start_here');
}
}
I also tried to command flash, with a button on another level, to only play a keyframe, labeled "start_here" if it is NOT at certain keyframes, which have the variable "already_played" assigned to them as an action.
I tried using the following code below, but again, the movie plays at "start_here" regardless of wheather it is at the variable or not.
on (release) {
if (_level2.already_played != "true") {
_level2.gotoAndPlay('start_here');
}
}
Any thoughts as to what I did wrong??
Thanks,
Peter
You can see the examples at:
http://santafe-websitedesign.com/test2/index2.html
click on 2.swf & 1.swf repeatedly to see the problem: the movie is not supposed to fade out again if its already stopped, (and invisible).
Play Label On Loaded Variable
Hello,
I have been searching google all day to find a solution to my problem.
I have a .swf file (in flash mx) with several labels: "10min" "30min" "40min"
On the first keyframe i have a dynamic text field named "tijdinfo" and has the variable name "tijd" that has to load the variable from outside the swf (i want to put the variable after the extension like *.swf?tijd=40) Now i want the correct keyframe to be played from the variable i use in html after my extension. So basically it has to play label "40min" when i say *.swf?tijd=40.
This is what i tried, but didn't help:
[keyframe1]
tijdinfo.loadVariables(tijd.text);
if (tijd == "40") {
gotoAndPlay("40min");
}
stop();
maybe anyone can help me.
Best regards,
Marcus
Using A Variable To Determine Which Clip To Play
Hello,
I am new to actionscript 3 (self taught but proficient in AS2) and am reading Moock's essential actionscript 3 to get my bearings but I have a question that I hope you can help me with so that as I read the book I can get some understanding of the fundamental differences between AS2 and AS3.
I am wondering why setting a string variable results in accessing an undefined method when I try to use that string to play a movie clip:
Code:
var lastClipPlayed:String = "someClip";
RedButton.addEventListener(MouseEvent.CLICK, redButtonClicked);
yellowButton.addEventListener(MouseEvent.CLICK, yellowButtonClicked);
function redButtonClicked( evt ) {
trace(lastClipPlayed);
lastClipPlayed.play();
redClip.gotoAndPlay(2);
lastClipPlayed = "redClip";
}
function yellowButtonClicked( evt ) {
trace(lastClipPlayed);
lastClipPlayed.play();
yellowClip.gotoAndPlay(2);
lastClipPlayed = "yellowClip";
}
the way I would have handled the same situation is AS2 is
Code:
var lastClipPlayed:String = "someClip"
yellowButton.onRelease = function(){
_root.lastClipPlayed.play();
yellowClip.play();
_root.lastClipPlayed = yellowClip
}
redButton.onRelease = function(){
_root.lastClipPlayed.play();
_root.lastClipPlayed = redClip
redClip.play();
}
Thanks for your help in getting started on understanding the differences
Using Variable To Make A Clip Play
Hello,
I am new to actionscript 3 (self taught but proficient in AS2) and am reading Moock's essential actionscript 3 to get my bearings but I have a question that I hope you can help me with so that as I read the book I can get some understanding of the fundamental differences between AS2 and AS3.
I have two buttons and two movie clips on the stage. Each movieclip has an alpha tween on it. When someone clicks on the button the clip fades in. If another button is clicked the clip should fade out while the next fades in.
I want to script entirely in the FLA and I have the code in frame 1 of the FLA. I am using a string variable to store the name of the clip and then using that variable to try to play the correct clip (making it fade out). I get a compile time error of implicit coercion of an object with static type string.
Is there a way to use a string to make an instance of a movieclip play?
I have included the clip below as well as a script that works for AS2. I have also attached the fla's below. Thanks for any help
Code:
var lastClipPlayed:String = "someClip";
RedButton.addEventListener(MouseEvent.CLICK, redButtonClicked);
yellowButton.addEventListener(MouseEvent.CLICK, yellowButtonClicked);
function redButtonClicked( evt ) {
trace(lastClipPlayed);
lastClipPlayed.play();
redClip.gotoAndPlay(2);
lastClipPlayed = "redClip";
}
function yellowButtonClicked( evt ) {
trace(lastClipPlayed);
lastClipPlayed.play();
yellowClip.gotoAndPlay(2);
lastClipPlayed = "yellowClip";
}
the way I would have handled the same situation is AS2 is
Code:
var lastClipPlayed:String = "someClip"
yellowButton.onRelease = function(){
_root.lastClipPlayed.play();
yellowClip.play();
_root.lastClipPlayed = yellowClip
}
redButton.onRelease = function(){
_root.lastClipPlayed.play();
_root.lastClipPlayed = redClip
redClip.play();
}
Thanks for your help in getting started on understanding the differences
How To Play A Variable Linked To Soundfile
Hi,
I have a variable named 'SoundFile' that's linked to a DB dir /audio/sound.mp3. How do I play this sound file with the variable?
I'm not that good at actionscripting
gr, toth
Flash Variable To Play MovieClip
Hi guys,
I am trying to get flash to play a MC based on a variable that is passed through..
I have a switch statement which i think would be best to use however this does not work.. so I guess it's not.. but you should be able to see what i'm trying to do with the code below.
I'm not sure if I need to have anything above this switch code to call the variable being passed through?
Code:
switch (page) {
case 'index':
_root.mc_home.gotoAndPlay(2);
case 'scout':
_root.mc_scout.gotoAndPlay(2);
case 'coaching':
_root.mc_coaching.gotoAndPlay(2);
case 'corner':
_root.mc_corner.gotoAndPlay(2);
case 'camps':
_root.mc_camps.gotoAndPlay(2);
default:
_root.mc_home.gotoAndPlay(2);
}
Any ideas... thanks heaps for any help.
Flash Intro - On Button Sound Play, Off Button Sound Off
Hello,
I am working on this flash project. I want to make it so that when you put your mouse on the button, it plays this song, but when you take your mouse off, it stops the song..sounds really easy, but I need some help. Thanks!
David
Not Getting Sound To Play
I have a sound file in my movie. When I click "play", I'm not hearing any sound (I know its not a hardware issue on my computer). Any suggestions on what might be the problem?
I tested the sound file before I imported it.
Thanks,
Why Does The Sound Play?
Hi,
In my flashmovie I use a sound in one place in one scen. Everything worked just fine.. and now suddenly the sound starts playing in other scens, seamingly random. WHY???
I haven't placed the sound in those sceans or in something I've used there...This puzzels and enoys me tremedously. would realy appreciate any thoughts..
Play Sound?
hi can somebody help me with play sound script??
cheers
Trying To Get Sound To Play
i'm using the attachSound command to start a sound on the click of a button. It works when i test the movie but when it is loaded into another movie the button doesn't trigger a thing?
This is the code on the button.
on (release) {
s = new Sound();
s.attachSound("amen");
_root.s.start(0,100);
_root.equal.gotoAndPlay ("on")
}
what am i doing wrong?
any help much appreciated..
Play Sound If... Else... ?
Hi,
I have created a quiz and want a particluar 'ding' sound to play if the user has the correct answer. If they have the incorrect answer I want a diferent sound to play. How can this be achieved using actionscript?
What do I need to add in order to get a different sound to play in the following script?
if (q1count == 25) {
question1 = "correct";
totalCorrect = totalCorrect+1;
} else {
question1 = "wrong";
totalWrong = totalWrong+1;
}
Any help is much appreciated. Thanks!
Glenn
Please Play Sound Only Once
i am writing a tutorial in flash, the questions r in text with acompanying sound, if the user gets something wrong they r presented with the question again, althogh i do not want to play the sound again . any clues appreciated.
Sound Play In An Exe
I have a exec made in flash (chapter1)which has some animation & sound playing in it. This file has an help button on click of which a help file opens but on doing so the sound in this file stops.
Now when i close the help file which is an exec and return back to the previous exe file (chapter1)the sound in the exe file should atomatically play.
Can anyone please help me on this asa possible as i am really stuckup on this matter.
thkz
Sound Keeps Going When I Play?
Why is it that when I go to Control>Play and test my animation and then when I try to stop it, the sound keeps going but my animation stops?
Sound Play
Hello,
I'm having trouble getting some music to play automatically when my sight loads and I can't figure it out.
The sound plays fine when I use the a regular button fuction like:
on (release) {
if (playing == undefined or playing == false) {
music = new Sound(this);
music.loadSound(tracks.firstChild.childNodes[nodeNum].attributes.path);
title = tracks.firstChild.childNodes[nodeNum].attributes.name;
music.start(0, 0);
}
}
When I tried to just strait apply it on the timeline, or on a MC using OnClipEvent(load) I got the same error that you see below.
Error opening URL "file:///D|/Projects%20Currrent/Misha%20Music/Dev/"
Does anyone know what control to use to make this work automatically, or any other suggestions.
Thanks, Jacob
Play Sound
Hi, im new to this so forgive me if this sounds like a stupid question. How can I get a sound to play if i press a key? Thanks very much.
Play Sound.
Hi folks,
How do i play a sound by using action script.
Thanks,
Ivorsmallun
Quote:
Don't knock it untill you've tried it...
Sound To Play Once Only ?
I have a 20sec mp3 that is placed in a key fm on the stage. This fm has a fm label
and is fm 25.
It plays fine. But of course every time the playhead returns to the fm the sound starts again and doubles and trebles etc over itself.
I would like it to play just the once and to loop.
Is there perhaps some form of 'if' statement that I could use so that
' if sound is playing do not play mysound.mp3'
I hope that that makes sense.
Thanks for any help
Trug
How To Play Sound?
i forgot how to import an mp3 file so it would play at sum tym in my flash movie..probably cuz i ddnt pay attention when the guy was explaining this at the course i went to hehe, i also want to kno if theres a way to cut the song and only use a part of it...
[F8] Play More Than One Sound At Once
Hi there! It's my first post - woohoo... Anyway I am pretty new to flash, I started learning yesterday pretty much and have to make something interactive in flash for my uni module by Friday. I'm doing pretty well so far having followed a few online tutorials which have been very cool. So here's my problem...
http://img441.imageshack.us/my.php?i...edflashtg1.swf
the first 3 buttons have a whoosh sound when you roll over them. But it doesn't seem to play more than one whoosh sound at the same time. Each button is an mc and on their individual timelines they have sounds on a sounds layer which are placed under a labels layer for each mouse state (_up _over _out and _splat)
so how can I make it play more than one sound? And why does it say [F8] by my post?
Can't Get Sound FX To Play Right
I am making my first game and I am starting to put sound effects in it for different events. I have it so that when you click the space key it sends the laser beam movie clip to frame 2 where the laser gun firing sound is in the time line. But if I press the sound several times within a few seconds the sound sometimes doesn't play.
I know that I can load the sound to a variable and then play it on a key press but I can't use any external files because that would use a lot of bandwidth on my server after the game is on a bunch of sites.
Is there a better way of doing this?
|