Help in soundEvent in AS3

i got an error message in my code(stop the music whenever i go to the

Page 1 of 1

6 Replies - 2108 Views - Last Post: 23 September 2009 - 11:19 AM

#1 123kid  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 7
  • Joined: 23-September 09

Help in soundEvent in AS3

Post icon  Posted 23 September 2009 - 06:52 AM

stop();


var BackGroundSound:soundBG = new soundBG();
var my_channel:SoundChannel = new SoundChannel();
my_channel = BackGroundSound.play();


start_btn.addEventListener(MouseEvent.CLICK, StartGame);


function StartGame(event:MouseEvent):void{
	gotoAndStop("play");
	my_channel = BackGroundSound.stop();
	}
	




hi
how i can stop the music from playing, whenever i click the button it shows an error message. i would like to happen is, whenever i click the button and go to the next frame the music will stop, but it didnt? can you help me about this? im a beginner here im developing my first game in flash cs3 using Action Script 3.0. thanks in advance and more power

below is the error message

[stop is not a function.
at SeaGhostGameTest_fla::MainTimeline/StartGame()]

im online ryt now at YM
yncy_chinese_ice@yahoo.com

This post has been edited by 123kid: 23 September 2009 - 07:18 AM


Is This A Good Question/Topic? 0
  • +

Replies To: Help in soundEvent in AS3

#2 KiKaL  Icon User is offline

  • D.I.C Head

Reputation: 0
  • View blog
  • Posts: 55
  • Joined: 09-October 02

Re: Help in soundEvent in AS3

Posted 23 September 2009 - 07:52 AM

have you tried my_channel.stop(); ?
Was This Post Helpful? 0
  • +
  • -

#3 123kid  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 7
  • Joined: 23-September 09

Re: Help in soundEvent in AS3

Posted 23 September 2009 - 08:07 AM

View PostKiKaL, on 23 Sep, 2009 - 06:52 AM, said:

have you tried my_channel.stop(); ?


hey..it works...i thought ive already tried that code, anyway..thanks man.
if its not too much, can i ask another one?

i want to end the game if the time runs out, can you provide me a code that i can base with. ive use conditional statement but it didnt work.

thanks again
123kid
Was This Post Helpful? 0
  • +
  • -

#4 KiKaL  Icon User is offline

  • D.I.C Head

Reputation: 0
  • View blog
  • Posts: 55
  • Joined: 09-October 02

Re: Help in soundEvent in AS3

Posted 23 September 2009 - 08:13 AM

I would have something such as

if(timer == 0){
//Code to go to game over screen
//So possibly something such as
scene.gotoAndPlay("Game Over");

};

It's hard to know for sure though because I do not know how you coded your game
Was This Post Helpful? 0
  • +
  • -

#5 123kid  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 7
  • Joined: 23-September 09

Re: Help in soundEvent in AS3

Posted 23 September 2009 - 08:25 AM

stop();



Mouse.hide();


var musicGame:gameMusic = new gameMusic();
var JellyGhost_mc:JellyGhost = new JellyGhost();
var randomX:Number;
var randomY:Number;
var randomScaleX:Number;
var randomScaleY:Number;
var count:Number = 10;
var myTimer:Timer = new Timer(1000,count);
var scoreTxt:int = 0;
var blow:blow_mc = new blow_mc();
var testLoad:Loader = new Loader();
var fireSplat:Splat = new Splat();
musicGame.play(0,100);
countDown.text = "10";

myTimer.addEventListener(TimerEvent.TIMER, countdown);
function countdown(event:TimerEvent):void {
countDown.text = String((count)-myTimer.currentCount);
}
myTimer.start();

[b]if(countDown.text == 0){
	gotoAndStop("mainGame");
	removeChild(JellyGhost_mc);
}[/b]









above is my code and below is the error message

(1176: Comparison between a value with static type String and a possibly unrelated type int.)

i think theres something wrong on my conditional statement?

This post has been edited by 123kid: 23 September 2009 - 08:26 AM

Was This Post Helpful? 0
  • +
  • -

#6 KiKaL  Icon User is offline

  • D.I.C Head

Reputation: 0
  • View blog
  • Posts: 55
  • Joined: 09-October 02

Re: Help in soundEvent in AS3

Posted 23 September 2009 - 08:50 AM

if(countDown.text == 0)

needs to be

if(countDown.text == "0")

You were comparing an integer to a string. 0 and "0" are not the same thing. Putting it in quotes tells it to compare it to the string "0".
Was This Post Helpful? 0
  • +
  • -

#7 123kid  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 7
  • Joined: 23-September 09

Re: Help in soundEvent in AS3

Posted 23 September 2009 - 11:19 AM

View PostKiKaL, on 23 Sep, 2009 - 07:50 AM, said:

if(countDown.text == 0)

needs to be

if(countDown.text == "0")

You were comparing an integer to a string. 0 and "0" are not the same thing. Putting it in quotes tells it to compare it to the string "0".


ive already tried it...it has no error but it didnt work.
it supposed to go on the next frame. countDown is a dynamic text.. i think countDown is not the right word to use.(did you get me?) do you have any idea why..?or any other way?

thanks again for the help Kikal. its aready 2am here, ill check later your response.

thank you.
123kid
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1