ActionScript 2.0 :: Play A Sound On HitTest?

Jul 11, 2009

ActionScript Code:
onClipEvent(enterFrame){
if(this.hitTest(_root.player)){
_root.coinsnd.play;
}
}

When the player touches the movie clip this sound will play, no errors found on this script but it doesn't work

View 3 Replies


Similar Posts:


ActionScript 1/2 :: Play A Sound Once If HitTest Is True?

Dec 31, 2010

I have 2 movieclips with instance names: bonus and platform. (and a movieclip inside platform with instance name: hit) I need a sound to play when hitTest is true.
Here is non-working code:

[Code]...

I dont see why this doesnt work. The sound is in the library with linkage name: snd50Points The trace("hit"); doesnt give an output when they do collide. I have a seperate hitTest that does give an output however, could this mean I cant have a hitTest of the same thing at once? I cant delete the onEnterFrame loops of the other hitTest because it has code that needs repeating. So yeah, I need a sound to play once when they collide and play the sound once again when they collide and so on.

View 5 Replies

ActionScript 2.0 :: Play A Sound Using "attachSound" And "start" With A "hitTest"?

Jul 24, 2006

What im trying to do is play a sound using "attachSound" and "start" with a "hitTest". I've exhausted everything i can think of and it still doesn't work.

View 2 Replies

HitTest Was Playing The Sound Over And Over?

May 20, 2009

I have a playhead that moves across the screen and when it hitTests a movie clip it plays a sound. all is working fine except that it will only work the first time it is played. The playhead is controlled by a button. I am working in Actionscrpt2. Here is the code on the movieclip:

onClipEvent(enterFrame)[code]....

In the begining I was having trouble because the hitTest was playing the sound over and over but the above code sorted that out. I think that the new problem was created by fixing the old one.

View 7 Replies

ActionScript 3.0 :: Stop Sound On Hittest

Jun 30, 2011

when the game starts im playing a simple song, and when my character falls, the sound should stop playing.[code]if ( player_mc.fall_mc.visible && player_mc.fall_mc.currentFrame == player_mc.fall_mc.totalFrames )// here when player falls, it plays a falling sound, but the main song wont stop, and when i restart the level, the main song starts again over the current playing song.[code]

View 2 Replies

ActionScript 2.0 :: Playing A Sound On Hittest?

Feb 18, 2005

Okay so i'm making this game, and I want it, so when the bar scrolls across the screen and hits the box it will play the sound inside the box mc.The code I have inside the box with the sound is.

onClipEvent (enterFrame)
{
if (this.hittest(_root.trackline))

[code].....

View 4 Replies

ActionScript 2.0 :: HitTest To Trigger Sound?

Nov 27, 2005

I'm a flash newbie working on a "game" for an architecture grad school class, using 2004 MX and and a Flash 8 demo. The game is a player in a street scene, where the user moves the player around with the arrow keys, and the up and down keys also zoom in and out. That part is working okay. My other objective is that when the player collides with any of the bulding facades, text describing the building would pop up, and a sound would be played. This is where I'm having trouble. I'm having some success with using hitTest to keep the player contained within the buildings, but great difficulting trying to get sound to play or text to appear when the player collides with a building front.

I converted one of the building facades on the "obstacles" layer to a movie clip ("snare3_mc"), with export to actionscipt checked. I'm trying to reference this movie clip in the "actions:Frame 1" code to play a sound when the player collides with it, and I'm also doing a test to see if it works by having it trace some text. I can get the trace to work for the "obstacles" layer with the buildings, but not specifically for the "obstacles.snare3_mc" facade (the green one). If I change line 123 of the code from "obstacles.snare3_mc" to just "obstacles", the trace text works, but I hope to have it specifically address the green building, not all of the buildings. Somehow I must not be properly loading or properly referencing the green object, my "snare3_mc" movie clip. Any ideas?.

Beyond not being able to specifically address the "snare3_mc" in the code to get the hitTest to even work, I can't get my audio clip to play no matter what I try. I'm trying to make the player's collision with this movie clip trigger the "snare3.wav" sound, but to no avail. The part of the code where I'm attempting this is the same hitTest with the trace text, lines 123-128 of the "actions:Frame1" code. Again, I'm probabl-y improperly loading or improperly addressing the sound in code.

The one other thing I want to do is to try and make text pop-up in a hidden box when the player collides with the green facade ("snare3_mc"). Ideally this text would appear out of nowhere when the player is in collision with the green facade, but dissapear entirely when the player moves away from the facade. I haven't even tried this yet in my .fla, but would want it as part of the same hitTest referred to above, lines 123-128.

Attached are 2004 MX and Flash 8 .fla files of this rough, ugly test version of my game.as the semester is winding down and my professor is not so into Flash or games. I feel like I am close, but really need help with these three little issues: properly referencing movie clips in the code for the hitTest, making the hitTest play a sound in my library, and making the hitTest pop up a text box with text while the player is colliding with the building facade.

View 1 Replies

ActionScript 2.0 :: Playing A Sound On Hittest

Feb 18, 2005

Okay so i'm making this game, and I want it, so when the bar scrolls across the screen and hits the box it will play the sound inside the box mc.

The code I have inside the box with the sound is.

onClipEvent (enterFrame)
{
if (this.hittest(_root.trackline))
{

[Code]....

View 4 Replies

ActionScript 2.0 :: Sound Plays Several Times During Hittest Instead Of Once

May 9, 2010

I posted a previous thread on this but i have found the problem but cant fix it!!

i have balls that can be thrown around the screen and when they touch i want them to play a specific sound to those balls.[code]...

View 0 Replies

ActionScript 3.0 :: Create Dynamic Sound To Play Sound-file?

Oct 14, 2009

It's possible to play a sound file through AS, either by loading it from a folder or import it to flash. It's also possible to play a dynamic tone with flash.media.Sound + writeFloat.

But... is it possible to play a sound file with flash.media.Sound + writeFloat in some way? I want to play a sound file without having to deal with any files except the .swf!

View 9 Replies

ActionScript 1/2 :: HitTest GoToAndPlay(2) - Play The Movie

Sep 26, 2010

when my character hits a certain object, I want it to play the movie. BUT since the hitTest is techincally always true if my character is just sitting on the object the entire time, it continuosly player frame #2. What is the simple fix for this? The code that will just play movie clip ONE TIME, and not restart continuosuly?

View 1 Replies

ActionScript 2.0 :: Hittest Random Goto And Play Help

Dec 31, 2010

I am trying to right a code that will help me make a random gotoAndPlay hits test script like you see the the popular game Pokemon. I have a character that is going over top of another movie clip but i want it to start generating random number and once it its a certain number i want it to go to the frame it is assigned to.[code]

View 2 Replies

ActionScript 2.0 :: Play Sound/stop Sound Button?

Feb 13, 2007

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.

View 13 Replies

IDE :: Add Sound - Sound To Play On The 'Over' State

Mar 6, 2009

I'm trying to add sound to some buttons. It's just a little metallic 'klink' sound that plays on rollover. I only want the sound to play on the 'Over' state. So I've set up a layer (just for sound) for the button and I add my sound in the 2nd frame (the Over state). Everything is cool. All is good. And the sound plays on rollover. But the sound also plays when I click the button (i.e. it also plays on the "Down" state). Why? The Down state keyframe is completely empty. What's going on here? I've only put the sound in the "Over" keyframe, why does it also play in the "Down" frame (or when I click)?

View 1 Replies

ActionScript 2.0 :: Play Sound Like "stop All Sound" Option In Flash?

May 17, 2003

I want to use a sound loop in my flash movie. The movie has many scenes. And the problem is that when I go to next scene or different scene I hear the sound repeating twice. I mean sound does not stop from first scene and begins from the different scenes.Is there any way to play sound like "stop all sound" option in Flash.

View 6 Replies

ActionScript 3.0 :: Play A Sound File And Show The Progress Of The Sound File Being Played

Mar 16, 2009

I have to play a sound file and show the progress of the sound file being played. I am using import flash.media.Sound; import flash.media.SoundChannel; But the PROGRESS event gives theprogress of loading of file. I want to know of much of the song has been played and how much more is left.

View 3 Replies

ActionScript 2.0 :: Swapping - Play The Client Side Mp3 First Then Only Play Server Side Sound Object Alternately

Aug 9, 2004

I am new to actionscript. I have created a script that will play server side sound object and client side mp3 files alternately. Now, I would like to play the client side mp3 first then only play server side sound object alternately. However, I have no idea how can I do so. The following is the code that need to be swapped:

[Code].....

View 2 Replies

ActionScript 2.0 :: Create An "hitTest" Script Inside A Movieclip That Is Actually Part Of That HitTest Code?

Jan 15, 2009

i just would like to know how to create an "hitTest" script inside a movieclip that is actually part of that hitTest code?I mean... I have mc A, and mc B. and the current hitTest code im using (that is on the timeline) makes mc A, destroy mc B when collide with it... but there are many mc B on the stage (with the same instance name) so, when mc A collide with one mc B, it destroys ALL mc's B... but i want it to destroy only the mc B that he collides, not all the others... maybe an hitTest script inside a movieclip B would work (somethig like "if MC A hitTest ME = i die" (not all the others)).

View 1 Replies

ActionScript 3.0 :: Can't Get More Than One Sound To Play

Jan 25, 2011

I am trying to build a simple xml based mp3 player for a project. I have got as far as combo/list boxes populating.

The first time you click the a track to play it all is well.

However, when you click another track, the first stops, but then I get error message.[code]...

View 2 Replies

Flash5 Sound Does Not Play Just Once

May 14, 2011

I tried modifying the sound in Action Script but now I do not get any sound on the webpage, only hear the sound in preview on flash editor.It was looping sound on the web page and I did not want to have surfers having to hit the stop button. But I did want it to play just once.[code]

View 1 Replies

How To Add In OnRelease Play Sound

Feb 14, 2012

I have a "onRelease function"
CODE:
btn_4.onRelease = function () {
var yTween = new mx.transitions.Tween(slider, "_x", mx.transitions.easing.Strong.easeOut, slider._x, 695 , 0.600000, true);
}
This works good but I like to add in a "onRelease" play sound, too. How it have to look like and where do I have to place the sound? Because: When I add in a new function "onRelease" both block each other.

View 2 Replies

ActionScript 2.0 :: How To Play Sound

Dec 14, 2009

I have two files as: A.swf and B.swf.[code]While I am playing B.swf then music is plays perfectly. While I load it to in A.swf then music in not playing.I don't want to change anything in B.swf like new Sound(this). I want actionscript code only for A.swf.

View 5 Replies

ActionScript 2.0 :: Sound Does Not Play

Jan 21, 2010

I've got 3 swf files and they are all nested. Here's the structure: [code]The sound clip "m1p1" is loaded in the library of "cc_mod1_shell.swf".This setup works when I just test "cc_mod1_shell.swf". I can hear the sound clip. But, when I test the root level "cc_ shell. swf", the sound does not play. Can anyone tell me what I'm doing wrong? Why would this._ parent work when I'm just using the 2 files in question, and not when they are nested in another file?.

View 7 Replies

ActionScript 2.0 :: Get Sound To Play?

Mar 27, 2012

How do you get sound to play?

I am importing the sound and exporting in with an identifier "sjump".

I am trying to play the sound from a seperate .as file with the following code:

var sound_sjump:Sound = new Sound();sound_sjump.attachSound("sjump");sound_sju mp.start(1,0);

Why won't it play?!

Some of my sounds like if I attach "coin" instead of "sjump" work? Why is this?

View 3 Replies

ActionScript 2.0 :: Sound Can't Play

Sep 7, 2008

I have a Flash movie that uses the following code to load a Sound from the library[code]...

View 4 Replies

IDE :: Can't Play/load Sound In CS3?

Jan 28, 2009

trying to make a play/pause toggle button in AS3. I'm a newbie but I've finished the site except for this element. my audio file works when i import to the library and it plays it in the preview. its in the same folder as the fla. working in cs3. This is what i've done.new as3 file. code.

var req:URLRequest = new URLRequest("ocean.mp3");
var s:Sound = new Sound(req);
s.play();

whats the deal? I get no compiler errors. i'm hitting option+Return on the mac to test the movie. I downloaded some one else's and it worked. i copied theirs into my project and it didn't work. i have a feeling its something to do with classes that i don't know about

View 1 Replies

IDE :: Way To Play Sound Files

May 2, 2010

I'm working on a game that loops a random sound file everytime the user goes to the menu. When I tried the simulate download in the preview menu, it took a long time to load the first frame (which is a preloader). I found the problem was that in the linkage for the sound files I said "Export on first frame" so i unchecked that box, but then when I tried playing again, the sound wouldn't load.So, I'm wondering, is there a way to play sound files through ActionScript without having to load them on the first frame?

View 1 Replies

ActionScript 2.0 :: Play Sound In Flash?

Feb 25, 2009

are there any possibilities to play sound in flash (actionscript 2), which is defined by a mathematical function like f(t) = 0.5*sin(2*Math.pi*16/27*440*t) ?

View 2 Replies

Sound To Play Only Once While Rest Keeps Looping?

Apr 3, 2009

to play only once and then stop but the camera flash to keep looping.The sound is on a separate layer, but whenever I put the 'stop' feature in the ActionScript, it stops the WHOLE THING, so the camera flashes only once.Again, I want the camera flash to repeat, but the click sound to play only once.

View 1 Replies

ActionScript 3.0 :: Play A Sound At A Certain Frame?

May 30, 2009

I would like to play a sound every time I reach frame 2, but I'm a bit confused with the code. I read some tutorials, but they were about 2.0 and the 3.0 ones were poorly explained.

Let's assume I imported a sound named 'ping.wav'. What do I need to do to play that sound on frame 2?

View 1 Replies







Copyrights 2005-15 www.BigResource.com, All rights reserved