..:: MX Studio Fóruns ::..: Som no Botão - ..:: MX Studio Fóruns ::..

Jump to content

Publicidade




ATENÇÃO

Para evitar posts desnecessários e que não influam para o andamento e desenvolvimento do fórum, clique aqui e leia todas as regras.
Page 1 of 1
  • You cannot start a new topic
  • You cannot reply to this topic

Som no Botão

#1 User is offline   victorhupo 

  • Group: Membros
  • Posts: 5
  • Joined: 17-July 11

Posted 24 September 2011 - 11:59 PM

Gostaria de fazer um botão que o tempo que a pessoa segurasse ele o som ficaria tocando e ai quando ela soutasse o som pararia gostaria de saber se isso eh possivel :lol:
0

#2 User is offline   RONYTORRES 

  • Group: Moderadores
  • Posts: 385
  • Joined: 07-December 06

Posted 29 September 2011 - 09:37 AM

Veja se seria isso:

AS2
som = new Sound();
som.loadSound("music.mp3",true);
som.stop();

var ativo:Boolean;

mc.onPress = function() {
	if (!ativo) {
		som.start();
		ativo = true;
	}
}

mc.onRelease = function() {
	som.stop();
	ativo = false;
}



AS3
var som:Sound = new Sound();
som.load(new URLRequest("music.mp3"));
var canal:SoundChannel = new SoundChannel();

var ativo:Boolean;

mc.addEventListener(MouseEvent.MOUSE_DOWN, _playSom);


function _playSom(e:MouseEvent):void {
	if (!ativo) {
		canal = som.play();
		ativo = true;
	}
	stage.addEventListener(MouseEvent.MOUSE_UP, _stopSom);
}

function _stopSom(e:MouseEvent):void {
	canal.stop();
	ativo = false;
	stage.removeEventListener(MouseEvent.MOUSE_UP, _stopSom);
}

0

#3 User is offline   victorhupo 

  • Group: Membros
  • Posts: 5
  • Joined: 17-July 11

Posted 15 October 2011 - 02:16 PM

View PostRONYTORRES, on 29 September 2011 - 09:37 AM, said:

Veja se seria isso:

AS2
som = new Sound();
som.loadSound("music.mp3",true);
som.stop();

var ativo:Boolean;

mc.onPress = function() {
	if (!ativo) {
		som.start();
		ativo = true;
	}
}

mc.onRelease = function() {
	som.stop();
	ativo = false;
}



AS3
var som:Sound = new Sound();
som.load(new URLRequest("music.mp3"));
var canal:SoundChannel = new SoundChannel();

var ativo:Boolean;

mc.addEventListener(MouseEvent.MOUSE_DOWN, _playSom);


function _playSom(e:MouseEvent):void {
	if (!ativo) {
		canal = som.play();
		ativo = true;
	}
	stage.addEventListener(MouseEvent.MOUSE_UP, _stopSom);
}

function _stopSom(e:MouseEvent):void {
	canal.stop();
	ativo = false;
	stage.removeEventListener(MouseEvent.MOUSE_UP, _stopSom);
}


vc pode me explicar como usar o codigo por que eu não estou conseguindo :D
0

Share this topic:


Page 1 of 1
  • You cannot start a new topic
  • You cannot reply to this topic



Publicidade




1 User(s) are reading this topic
0 membro(s), 1 visitante(s) e 0 membros anônimo(s)