Pagina 1 din 1

Efect beat boxe

Scris: Lun Aug 22, 2011
de George02
Salut cum as puta realiza un efect de beat la boxe atunci cand se aude o melodie?
Am urmatorul script:

Cod: Selectaţi tot

btnPlay.addEventListener(MouseEvent.CLICK , playMusic);

function playMusic(evt:MouseEvent):void{
	myMusic.load(soundFile);
	channel = myMusic.play();
	myTimer.start();
}
Deci vreau ca atunci cand melodia incepe sa porneasca movie clip de la alt Layer sau nu stiu cumva cu actionscript sa se mareasca height si widht pentru a se creea un efect de beat in boxe.

Efect beat boxe

Scris: Lun Aug 22, 2011
de MarPlo
Salut
Ca idee, ai putea adauga inca un Keyframe, la fel cu cel in care e butonul, doar ca in locul butonului in al doilea Frame sa pui un MovieClip cu acel efect.
Apoi, in primul Frame adagi stop() la inceput, sa se opreasca prezentarea aici, iar in functia apelata la click adaugi sa faca salt-si-stop la Frame 2.
Iar in Frame 2 sa fie inregistrat un eveniment la click pe MovieClip care sa faca salt si stop la Frame1
Cam asa:
Frame 1:

Cod: Selectaţi tot

stop();
btnPlay.addEventListener(MouseEvent.CLICK , playMusic);

function playMusic(evt:MouseEvent):void{
   myMusic.load(soundFile);
   channel = myMusic.play();
   myTimer.start();
  gotoAndStop(2);
}
Frame 2:

Cod: Selectaţi tot

instanta_movieclip.addEventListener(MouseEvent.CLICK, gotoFr1);

function gotoFr1(event:MouseEvent):void
{
	gotoAndStop(1);
}

Efect beat boxe

Scris: Mar Aug 23, 2011
de George02
am gasit exact ce vroiam http://www.developphp.com/Flash_tutoria ... ers_and_EQ

Pe un layer am acest cod AS3 care face sa porneasca o melodie la click iar pe alt layer am codul pentru efectul de boxe

Cod: Selectaţi tot

var my_songs:XMLList;
var my_total:Number;

var my_sound:Sound;
var my_channel:SoundChannel;

var current_song:Number = 0;

var song_position:Number;
var song_paused:Boolean;

var myXMLLoader:URLLoader = new URLLoader();
myXMLLoader.load(new URLRequest("player.xml"));
myXMLLoader.addEventListener(Event.COMPLETE, processXML);

function processXML(e:Event):void {
	var myXML:XML = new XML(e.target.data);

	my_songs = myXML.SONG;
	my_total = my_songs.length();

	//playSong(0);

	myXMLLoader.removeEventListener(Event.COMPLETE, processXML);
	myXMLLoader = null;

}

function playSong(mySong:Number):void {
	var myTitle = my_songs[mySong].@TITLE;
	var myArtist = my_songs[mySong].@ARTIST;
	var myURL = my_songs[mySong].@URL;

	title_txt.text = myTitle;
	artist_txt.text = myArtist;

	if (my_channel) {
		my_channel.stop();
		my_channel.removeEventListener(Event.SOUND_COMPLETE, onNext);
	}

	my_sound = new Sound();
	my_sound.load(new URLRequest(myURL));
	my_channel = my_sound.play();
	my_channel.addEventListener(Event.SOUND_COMPLETE, onNext);
}

next_btn.addEventListener(MouseEvent.CLICK, onNext);
function onNext(e:Event):void {
	current_song++;
	if (current_song>=my_total) {
		current_song=0;
	}
	playSong(current_song);
}
prev_btn.addEventListener(MouseEvent.CLICK, onPrev);
function onPrev(e:MouseEvent):void {
	current_song--;
	if (current_song<0) {
		current_song = my_total-1;
	}
	playSong(current_song);
}

pause_btn.addEventListener(MouseEvent.CLICK, onPause);
function onPause(e:MouseEvent):void {
	if (my_channel) {
		song_position = my_channel.position;
		my_channel.stop();
		song_paused=true;
	}
}
play_btn.addEventListener(MouseEvent.CLICK, onPlay);
function onPlay(e:MouseEvent):void {
	if (song_paused) {
		my_channel = my_sound.play(song_position);
		song_paused=false;
	} else if (!my_channel) {
		playSong(current_song);
	}
}
Efectul de boxe

Cod: Selectaţi tot

stop();
// Set Boolean value for buttons Play and Stop functions below
var isPlaying:Boolean = false;
isPlaying = true; 
// Add listener to trigger [onEnterFrame] function below
addEventListener(Event.ENTER_FRAME, onEnterFrame);

//snd.addEventListener(Event.SOUND_COMPLETE, onPlaybackComplete);

var bytes:ByteArray = new ByteArray();

function onEnterFrame(event:Event):void
{
    SoundMixer.computeSpectrum(bytes, false, 0);
    
// SPEAKER 1 BOUNCE
spkr1.width = ( Math.round(my_channel.rightPeak * 5) ) + 66; // 66 is speaker width
spkr1.height = ( Math.round(my_channel.rightPeak * 5) ) + 66; // 66 is speaker height

// SPEAKER 2 BOUNCE
spkr2.width = ( Math.round(my_channel.rightPeak * 5) ) + 66; // 66 is speaker width
spkr2.height = ( Math.round(my_channel.rightPeak * 5) ) + 66; // 66 is speaker height
	
// SPEAKER 3 BOUNCE
spkr3.width = ( Math.round(my_channel.leftPeak * 4) ) + 30; // 30 is speaker width
spkr3.height = ( Math.round(my_channel.leftPeak * 4) ) + 30; // 30 is speaker height

// SPEAKER 4 BOUNCE
spkr4.width = ( Math.round(my_channel.leftPeak * 4) ) + 30; // 30 is speaker width
spkr4.height = ( Math.round(my_channel.leftPeak * 4) ) + 30; // 30 is speaker height
	
}

Dar primesc urmatoarea eroare:

Cod: Selectaţi tot

TypeError: Error #1009: Cannot access a property or method of a null object reference.
	at radio_fla::MainTimeline/onEnterFrame()
Ma poti ajuta?

Efect beat boxe

Scris: Mar Aug 23, 2011
de MarPlo
Nu prea ma pricep la ActionScript, dar pot spune ca din eroare rezulta folosirea unei proprietati sau metode nedefinite, aplicate la o instanta de obiect ce folosese o clasa care nu a fost importata in script.
Dar nu stiu ce clasa.
De exemplu, pentru lucru cu timeline trebuie clasa Timer.
In pagina cu acel tutorial am vazut ca e "Download source Files", poate alea functioneaza ca sa vezi ce lipseste, sau poti intreba direct acolo, la "Add a comment".