Ir para conteúdo

POWERED BY:

Arquivado

Este tópico foi arquivado e está fechado para novas respostas.

Fecareis

Como adiconar mais um botão a este flash

Recommended Posts

Ola Boa tarde estou precisando de ajuda a este seguinte flash

http://hollysandalias.com.br/menu.html

Download do arquivo .fla

http://hollysandalias.com.br/download.zip

 

 

Ele funciona com três botões mas quando coloco o 4 o action da este erro

 

TypeError: Error #1010: Um termo é indefinido e não tem propriedades.

at menu_fla::MainTimeline/loadButtons()

at menu_fla::MainTimeline/frame1()

 

e o efeito não funciona

 

O que faço como adicionar mais um botão

 

muito obrigado

Compartilhar este post


Link para o post
Compartilhar em outros sites

Bom, não tenho domínio no action, mesmo assim dei uma furungada no seu fla.

Adicionei o quarto botão (btnRedBig_2) e uma linha a mais no código, o efeito funciona, mas dá um erro diferente, no compilador (nada em output):

timerGreen.addEventListener(TimerEvent.TIMER, moveGreen); 

Imagem com 4 botões: Clique aqui

 

Isso vai além do meu conhecimento, espero que outro colega possa auxiliar, eis o código:

loadButtons(); //load the listeners

function loadButtons():void {
	btnGreenBig.buttonBackGreen.useHandCursor=true;
	btnGreenBig.buttonBackGreen.buttonMode=true;
	
	btnRedBig.buttonBackRed.useHandCursor=true;
	btnRedBig.buttonBackRed.buttonMode=true;
	
	btnBlueBig.buttonBackBlue.useHandCursor=true;
	btnBlueBig.buttonBackBlue.buttonMode=true;
	
	btnRedBig_2.buttonBackRed_2.useHandCursor=true;
	btnRedBig_2.buttonBackRed_2.buttonMode=true;
	
	btnGreenBig.buttonBackGreen.addEventListener(MouseEvent.MOUSE_OVER, onMouseOver);
	btnGreenBig.buttonBackGreen.addEventListener(MouseEvent.MOUSE_OUT, onMouseOut);
	btnGreenBig.buttonBackGreen.addEventListener(MouseEvent.CLICK, onMouseClick);
	
	btnBlueBig.buttonBackBlue.addEventListener(MouseEvent.MOUSE_OVER, onMouseOver);
	btnBlueBig.buttonBackBlue.addEventListener(MouseEvent.MOUSE_OUT, onMouseOut);
	btnBlueBig.buttonBackBlue.addEventListener(MouseEvent.CLICK, onMouseClick);
	
	btnRedBig.buttonBackRed.addEventListener(MouseEvent.MOUSE_OVER, onMouseOver);
	btnRedBig.buttonBackRed.addEventListener(MouseEvent.MOUSE_OUT, onMouseOut);
	btnRedBig.buttonBackRed.addEventListener(MouseEvent.CLICK, onMouseClick);
	
	btnRedBig.buttonBackRed_2.addEventListener(MouseEvent.MOUSE_OVER, onMouseOver);
	btnRedBig.buttonBackRed_2.addEventListener(MouseEvent.MOUSE_OUT, onMouseOut);
	btnRedBig.buttonBackRed_2.addEventListener(MouseEvent.CLICK, onMouseClick);
}

//the glow filters to apply the swirl
var glR:GlowFilter = new GlowFilter(0xcc0000,1,50,50,2.5);
var glG:GlowFilter = new GlowFilter(0x91e600,1,50,50,2);
var glB:GlowFilter = new GlowFilter(0x0033ff,1,50,50,3.5);

//mouse over handler
function onMouseOver(evt:MouseEvent):void {
	switch(evt.currentTarget.name) { //this is one way to find if the mouseOver is dispatched from the buttonBack MC
		case "buttonBackGreen":
			btnGreenBig.homeOverSwirl.gotoAndPlay(2); //animate the swirl grow
			btnGreenBig.homeLabel.gotoAndStop(2); //put the label on white
			btnGreenBig.homeOverSwirl.filters=[glG]; //applay filters to the swirl
			Mstatus.text="mouseOver Home!"; //update button status text
			startTimer(btnGreenBig); //start the timer to animate the cricular move of button
		break;
		case "buttonBackBlue":  //same as on the green button
			btnBlueBig.contactOverSwirl.gotoAndPlay(2);
			btnBlueBig.contactLabel.gotoAndStop(2);
			btnBlueBig.contactOverSwirl.filters=[glB];
			Mstatus.text="mouseOver Contact!";
			startTimer(btnBlueBig);
		break;
		case "buttonBackRed": //same as on the green button
			btnRedBig.aboutOverSwirl.gotoAndPlay(2);
			btnRedBig.aboutLabel.gotoAndStop(2);
			btnRedBig.aboutOverSwirl.filters=[glR];
			Mstatus.text="mouseOver About!";
			startTimer(btnRedBig);
		break;
		case "buttonBackRed_2": //same as on the green button
			btnRedBig_2.aboutOverSwirl.gotoAndPlay(2);
			btnRedBig_2.aboutLabel.gotoAndStop(2);
			btnRedBig_2.aboutOverSwirl.filters=[glR];
			Mstatus.text="mouseOver About!";
			startTimer(btnRedBig_2);
		break;
	}
}

//mouse out handler
function onMouseOut(evt:MouseEvent):void {
	switch(evt.target) { //this is another way to check if the event is dispatched from buttonBack MC
		case btnGreenBig.buttonBackGreen:
			btnGreenBig.homeOverSwirl.gotoAndPlay("fade"); //play the fade effect
			btnGreenBig.homeLabel.gotoAndStop(1); //return label to his original color
			Mstatus.text="mouseOut Home!"; //update status text
			stopTimer(btnGreenBig); //stop the circular move
		break;
		case btnBlueBig.buttonBackBlue: //sabe as green button
			btnBlueBig.contactOverSwirl.gotoAndPlay("fade");
			btnBlueBig.contactLabel.gotoAndStop(1);
			Mstatus.text="mouseOut Contact!";
			stopTimer(btnBlueBig);
		break;
		case btnRedBig.buttonBackRed: //sabe as green button		
			btnRedBig.aboutOverSwirl.gotoAndPlay("fade");
			btnRedBig.aboutLabel.gotoAndStop(1);
			stopTimer(btnRedBig);
			Mstatus.text="mouseOut About!";
		break;
		case btnRedBig_2.buttonBackRed: //sabe as green button		
			btnRedBig_2.aboutOverSwirl.gotoAndPlay("fade");
			btnRedBig_2.aboutLabel.gotoAndStop(1);
			stopTimer(btnRedBig_2); 
			Mstatus.text="mouseOut About!";
		break;
	}
}

//click handler
function onMouseClick(evt:MouseEvent):void {
	switch(evt.currentTarget.name) {
		case "buttonBackGreen":
			Mstatus.text="mouseClick Home!";
		break;
		case "buttonBackBlue":	
			Mstatus.text="mouseClick Contact!";
		break;
		case "buttonBackRed":
			Mstatus.text="mouseClick About!";
		break;
		case "buttonBackRed_2":
			Mstatus.text="mouseClick About!";
		break;
	}
}


/***circular animation ***/
var distance:Number = 0.4; //circular distance
var speed:Number=20; //more hight, less speed

//button timers to do the circular move
var time:Timer = new Timer(speed); //green one
var timerBlue:Timer = new Timer(speed); //blue
var timerRed:Timer = new Timer(speed); //red
var timerGreen:Timer = new Timer(speed); //ADICIONEI ESTA LINHA
var timerRed_2:Timer = new Timer(speed); //red_2

//listeners to update button position
time.addEventListener(TimerEvent.TIMER, moveCircle);
timerRed.addEventListener(TimerEvent.TIMER, moveRed);
timerBlue.addEventListener(TimerEvent.TIMER, moveBlue);
timerGreen.addEventListener(TimerEvent.TIMER, moveGreen); 
timerRed_2.addEventListener(TimerEvent.TIMER, moveRed_2);

//current rotation angle position
var angle:Number=0;
var angleB:Number = 0;
var angleR:Number = 0;

//green circular function
function moveCircle (e:TimerEvent):void {
	btnGreenBig.x = btnGreenBig.x + (Math.cos(angle) * distance);
	btnGreenBig.y = btnGreenBig.y + (Math.sin(angle) * distance)
	angle += 0.1;
}

//red circular function
function moveRed (e:TimerEvent):void {
	btnRedBig.x = btnRedBig.x + Math.cos(angleR) * distance;
	btnRedBig.y = btnRedBig.y + Math.sin(angleR) * distance;
	angleR += 0.1;
}

//blue circular function
function moveBlue(e:TimerEvent):void {
	btnBlueBig.x = btnBlueBig.x + Math.cos(angleB) * distance;
	btnBlueBig.y = btnBlueBig.y + Math.sin(angleB) * distance;
	angleB += 0.1;
}

//red_2 circular function
function moveRed_2 (e:TimerEvent):void {
	btnRedBig_2.x = btnRedBig_2.x + Math.cos(angleR) * distance;
	btnRedBig_2.y = btnRedBig_2.y + Math.sin(angleR) * distance;
	angleR += 0.1;
}

//start timer/circular anim on the provided movieclip.
function startTimer(it:MovieClip):void {
	if(it==btnGreenBig) time.start();
	if(it==btnRedBig) timerRed.start();
	if(it==btnBlueBig) timerBlue.start();
	if(it==btnRedBig_2) timerRed_2.start();
}
//stop timer/circular anim
function stopTimer(it:MovieClip):void {
	if(it==btnGreenBig) time.stop();
	if(it==btnRedBig) timerRed.stop();
	if(it==btnBlueBig) timerBlue.stop();
	if(it==btnRedBig_2) timerRed_2.stop();
}

Compartilhar este post


Link para o post
Compartilhar em outros sites

Provavelmente seu erro é o seguinte:

 

você trabalha com a instancia do botão no palco, e com a instancia dentro de cada botão. Pelo seu erro, acho que você adicionou outro botão no palco colocou outro nome de instancia, mas não mudou o nome do objeto dentro do botão, ou se mudou, mudou sem duplicar o botão no palco, o q fez o objeto original ficar errado.

 

antes de falar como fiz, uma dica: Se você usar OOP, criando uma classe para ser esses botões, você vai economizar muito código, e tornar-lo muito mais fácil de manter/adicionar/remover/etc.

 

enfim... me baseei no código da Elektra, que já tinha uma boa parte do que precisava. você precisa duplicar um dos objetos de botão na sua biblioteca (myButtonBlue, myButtonGreen, myButtonRed), fazendo as modificações necessárias (no meu caso só dupliquei, não mudei nada, e dei o nome btnRedBig_2). Dentro desse MC que você duplicou, você precisa mudar o nome de instancia dos elementos que estão recebendo os eventos de mouse (buttonBackRed ou buttonBackGreen ou buttonBackBlue). No meu caso, mudei para buttonBackRed_2.

 

Depois disso é só colocar os códigos para cada efeito/evento desejado, como nos outros botões, prestando atenção aos nomes de instancia que devem ser usados.

 

Meu código ficou assim (algumas coisas que tirei, deixei comentado):

 

loadButtons(); //load the listeners

function loadButtons():void {
		
        btnGreenBig.buttonBackGreen.useHandCursor=true;
        btnGreenBig.buttonBackGreen.buttonMode=true;
        
        btnRedBig.buttonBackRed.useHandCursor=true;
        btnRedBig.buttonBackRed.buttonMode=true;
        
        btnBlueBig.buttonBackBlue.useHandCursor=true;
        btnBlueBig.buttonBackBlue.buttonMode=true;
        
        btnRedBig_2.buttonBackRed_2.useHandCursor=true;
        btnRedBig_2.buttonBackRed_2.buttonMode=true;
        
        btnGreenBig.buttonBackGreen.addEventListener(MouseEvent.MOUSE_OVER, onmouseover);
        btnGreenBig.buttonBackGreen.addEventListener(MouseEvent.MOUSE_OUT, onmouseout);
        btnGreenBig.buttonBackGreen.addEventListener(MouseEvent.CLICK, onMouseClick);
        
        btnBlueBig.buttonBackBlue.addEventListener(MouseEvent.MOUSE_OVER, onmouseover);
        btnBlueBig.buttonBackBlue.addEventListener(MouseEvent.MOUSE_OUT, onmouseout);
        btnBlueBig.buttonBackBlue.addEventListener(MouseEvent.CLICK, onMouseClick);
        
        btnRedBig.buttonBackRed.addEventListener(MouseEvent.MOUSE_OVER, onmouseover);
        btnRedBig.buttonBackRed.addEventListener(MouseEvent.MOUSE_OUT, onmouseout);
        btnRedBig.buttonBackRed.addEventListener(MouseEvent.CLICK, onMouseClick);
        
        btnRedBig_2.buttonBackRed_2.addEventListener(MouseEvent.MOUSE_OVER, onmouseover);
        btnRedBig_2.buttonBackRed_2.addEventListener(MouseEvent.MOUSE_OUT, onmouseout);
        btnRedBig_2.buttonBackRed_2.addEventListener(MouseEvent.CLICK, onMouseClick);
}

//the glow filters to apply the swirl
var glR:GlowFilter = new GlowFilter(0xcc0000,1,50,50,2.5);
var glG:GlowFilter = new GlowFilter(0x91e600,1,50,50,2);
var glB:GlowFilter = new GlowFilter(0x0033ff,1,50,50,3.5);

//mouse over handler
function onmouseover(evt:MouseEvent):void {
        switch(evt.currentTarget.name) { //this is one way to find if the mouseOver is dispatched from the buttonBack MC
                case "buttonBackGreen":
                        btnGreenBig.homeOverSwirl.gotoAndPlay(2); //animate the swirl grow
                        btnGreenBig.homeLabel.gotoAndStop(2); //put the label on white
                        btnGreenBig.homeOverSwirl.filters=[glG]; //applay filters to the swirl
                        Mstatus.text="mouseOver Home!"; //update button status text
                        startTimer(btnGreenBig); //start the timer to animate the cricular move of button
                break;
                case "buttonBackBlue":  //same as on the green button
                        btnBlueBig.contactOverSwirl.gotoAndPlay(2);
                        btnBlueBig.contactLabel.gotoAndStop(2);
                        btnBlueBig.contactOverSwirl.filters=[glB];
                        Mstatus.text="mouseOver Contact!";
                        startTimer(btnBlueBig);
                break;
                case "buttonBackRed": //same as on the green button
                        btnRedBig.aboutOverSwirl.gotoAndPlay(2);
                        btnRedBig.aboutLabel.gotoAndStop(2);
                        btnRedBig.aboutOverSwirl.filters=[glR];
                        Mstatus.text="mouseOver About!";
                        startTimer(btnRedBig);
                break;
                case "buttonBackRed_2": //same as on the green button
                        btnRedBig_2.aboutOverSwirl.gotoAndPlay(2);
                        btnRedBig_2.aboutLabel.gotoAndStop(2);
                        btnRedBig_2.aboutOverSwirl.filters=[glR];
                        Mstatus.text="mouseOver About 2!";
                        startTimer(btnRedBig_2);
                break;
        }
}

//mouse out handler
function onmouseout(evt:MouseEvent):void {
       switch(evt.target) { //this is another way to check if the event is dispatched from buttonBack MC
                case btnGreenBig.buttonBackGreen:
                        btnGreenBig.homeOverSwirl.gotoAndPlay("fade"); //play the fade effect
                        btnGreenBig.homeLabel.gotoAndStop(1); //return label to his original color
                        Mstatus.text="mouseOut Home!"; //update status text
                        stopTimer(btnGreenBig); //stop the circular move
                break;
                case btnBlueBig.buttonBackBlue: //sabe as green button
                        btnBlueBig.contactOverSwirl.gotoAndPlay("fade");
                        btnBlueBig.contactLabel.gotoAndStop(1);
                        Mstatus.text="mouseOut Contact!";
                        stopTimer(btnBlueBig);
                break;
                case btnRedBig.buttonBackRed: //sabe as green button            
                        btnRedBig.aboutOverSwirl.gotoAndPlay("fade");
                        btnRedBig.aboutLabel.gotoAndStop(1);
                        stopTimer(btnRedBig);
                        Mstatus.text="mouseOut About!";
                break;
                case btnRedBig_2.buttonBackRed_2: //sabe as green button          
                        btnRedBig_2.aboutOverSwirl.gotoAndPlay("fade");
                        btnRedBig_2.aboutLabel.gotoAndStop(1);
                        stopTimer(btnRedBig_2); 
                        Mstatus.text="mouseOut About!";
                break;
        }
}

//click handler
function onMouseClick(evt:MouseEvent):void {
        switch(evt.currentTarget.name) {
                case "buttonBackGreen":
                        Mstatus.text="mouseClick Home!";
                break;
                case "buttonBackBlue":  
                        Mstatus.text="mouseClick Contact!";
                break;
                case "buttonBackRed":
                        Mstatus.text="mouseClick About!";
                break;
                case "buttonBackRed_2":
                        Mstatus.text="mouseClick About 2!";
                break;
        }
}


/***circular animation ***/
var distance:Number = 0.4; //circular distance
var speed:Number=20; //more hight, less speed

//button timers to do the circular move
//var time:Timer = new Timer(speed); //green one
var timerBlue:Timer = new Timer(speed); //blue
var timerRed:Timer = new Timer(speed); //red
var timerGreen:Timer = new Timer(speed); //ADICIONEI ESTA LINHA
var timerRed_2:Timer = new Timer(speed); //red_2

//listeners to update button position
//time.addEventListener(TimerEvent.TIMER, moveCircle);
timerRed.addEventListener(TimerEvent.TIMER, moveRed);
timerBlue.addEventListener(TimerEvent.TIMER, moveBlue);
timerGreen.addEventListener(TimerEvent.TIMER, moveGreen); 
timerRed_2.addEventListener(TimerEvent.TIMER, moveRed_2);

//current rotation angle position
var angle:Number=0;
var angleB:Number = 0;
var angleR:Number = 0;

//green circular function
function moveGreen (e:TimerEvent):void {
        btnGreenBig.x = btnGreenBig.x + (Math.cos(angle) * distance);
        btnGreenBig.y = btnGreenBig.y + (Math.sin(angle) * distance)
        angle += 0.1;
}

//red circular function
function moveRed (e:TimerEvent):void {
        btnRedBig.x = btnRedBig.x + Math.cos(angleR) * distance;
        btnRedBig.y = btnRedBig.y + Math.sin(angleR) * distance;
        angleR += 0.1;
}

//blue circular function
function moveBlue(e:TimerEvent):void {
        btnBlueBig.x = btnBlueBig.x + Math.cos(angleB) * distance;
        btnBlueBig.y = btnBlueBig.y + Math.sin(angleB) * distance;
        angleB += 0.1;
}

//red_2 circular function
function moveRed_2 (e:TimerEvent):void {
        btnRedBig_2.x = btnRedBig_2.x + Math.cos(angleR) * distance;
        btnRedBig_2.y = btnRedBig_2.y + Math.sin(angleR) * distance;
        angleR += 0.1;
}

//start timer/circular anim on the provided movieclip.
function startTimer(it:MovieClip):void {
        if(it==btnGreenBig) timerGreen.start();
        if(it==btnRedBig) timerRed.start();
        if(it==btnBlueBig) timerBlue.start();
        if(it==btnRedBig_2) timerRed_2.start();
}
//stop timer/circular anim
function stopTimer(it:MovieClip):void {
        if(it==btnGreenBig) timerGreen.stop();
        if(it==btnRedBig) timerRed.stop();
        if(it==btnBlueBig) timerBlue.stop();
        if(it==btnRedBig_2) timerRed_2.stop();
}

o arquivo: http://www.4shared.com/file/165983493/1dc165bb/temp.html

 

OBS.: provavelmente a fonte que você usou para o campo de texto abaixo foi mudada, já q eu não a tenho aqui.

Compartilhar este post


Link para o post
Compartilhar em outros sites

este é o que funciona e tem 3 botões

 

loadButtons(); //load the listeners

function loadButtons():void {
	btnGreenBig.buttonBackGreen.useHandCursor=true;
	btnGreenBig.buttonBackGreen.buttonMode=true;
	
	btnRedBig.buttonBackRed.useHandCursor=true;
	btnRedBig.buttonBackRed.buttonMode=true;
	
	btnBlueBig.buttonBackBlue.useHandCursor=true;
	btnBlueBig.buttonBackBlue.buttonMode=true;
	
	btnGreenBig.buttonBackGreen.addEventListener(MouseEvent.MOUSE_OVER, onmouseover);
	btnGreenBig.buttonBackGreen.addEventListener(MouseEvent.MOUSE_OUT, onmouseout);
	btnGreenBig.buttonBackGreen.addEventListener(MouseEvent.CLICK, onMouseClick);
	
	btnBlueBig.buttonBackBlue.addEventListener(MouseEvent.MOUSE_OVER, onmouseover);
	btnBlueBig.buttonBackBlue.addEventListener(MouseEvent.MOUSE_OUT, onmouseout);
	btnBlueBig.buttonBackBlue.addEventListener(MouseEvent.CLICK, onMouseClick);
	
	btnRedBig.buttonBackRed.addEventListener(MouseEvent.MOUSE_OVER, onmouseover);
	btnRedBig.buttonBackRed.addEventListener(MouseEvent.MOUSE_OUT, onmouseout);
	btnRedBig.buttonBackRed.addEventListener(MouseEvent.CLICK, onMouseClick);
}

//the glow filters to apply the swirl
var glR:GlowFilter = new GlowFilter(0xcc0000,1,50,50,2.5);
var glG:GlowFilter = new GlowFilter(0x91e600,1,50,50,2);
var glB:GlowFilter = new GlowFilter(0x0033ff,1,50,50,3.5);

//mouse over handler
function onmouseover(evt:MouseEvent):void {
	switch(evt.currentTarget.name) { //this is one way to find if the mouseOver is dispatched from the buttonBack MC
		case "buttonBackGreen":
			btnGreenBig.homeOverSwirl.gotoAndPlay(2); //animate the swirl grow
			btnGreenBig.homeLabel.gotoAndStop(2); //put the label on white
			btnGreenBig.homeOverSwirl.filters=[glG]; //applay filters to the swirl
			Mstatus.text="mouseOver Home!"; //update button status text
			startTimer(btnGreenBig); //start the timer to animate the cricular move of button
		break;
		case "buttonBackBlue": //same as on the green button
			btnBlueBig.contactOverSwirl.gotoAndPlay(2);
			btnBlueBig.contactLabel.gotoAndStop(2);
			btnBlueBig.contactOverSwirl.filters=[glB];
			Mstatus.text="mouseOver Contact!";
			startTimer(btnBlueBig);
		break;
		case "buttonBackRed": //same as on the green button
			btnRedBig.aboutOverSwirl.gotoAndPlay(2);
			btnRedBig.aboutLabel.gotoAndStop(2);
			btnRedBig.aboutOverSwirl.filters=[glR];
			Mstatus.text="mouseOver About!";
			startTimer(btnRedBig);
		break;
	}
}

//mouse out handler
function onmouseout(evt:MouseEvent):void {
	switch(evt.target) { //this is another way to check if the event is dispatched from buttonBack MC
		case btnGreenBig.buttonBackGreen:
			btnGreenBig.homeOverSwirl.gotoAndPlay("fade"); //play the fade effect
			btnGreenBig.homeLabel.gotoAndStop(1); //return label to his original color
			Mstatus.text="mouseOut Home!"; //update status text
			stopTimer(btnGreenBig); //stop the circular move
		break;
		case btnBlueBig.buttonBackBlue: //sabe as green button
			btnBlueBig.contactOverSwirl.gotoAndPlay("fade");
			btnBlueBig.contactLabel.gotoAndStop(1);
			Mstatus.text="mouseOut Contact!";
			stopTimer(btnBlueBig);
		break;
		case btnRedBig.buttonBackRed: //sabe as green button		
			btnRedBig.aboutOverSwirl.gotoAndPlay("fade");
			btnRedBig.aboutLabel.gotoAndStop(1);
			stopTimer(btnRedBig);
			Mstatus.text="mouseOut About!";
		break;
	}
}

//click handler
function onMouseClick(evt:MouseEvent):void {
	switch(evt.currentTarget.name) {
		case "buttonBackGreen":
			Mstatus.text="mouseClick Home!";
		break;
		case "buttonBackBlue":	
			Mstatus.text="mouseClick Contact!";
		break;
		case "buttonBackRed":
			Mstatus.text="mouseClick About!";
		break;
	}
}


/***circular animation ***/
var distance:Number = 0.4; //circular distance
var speed:Number=20; //more hight, less speed

//button timers to do the circular move
var time:Timer = new Timer(speed); //green one
var timerBlue:Timer = new Timer(speed); //blue
var timerRed:Timer = new Timer(speed); //red
//listeners to update button position
time.addEventListener(TimerEvent.TIMER, moveCircle);
timerRed.addEventListener(TimerEvent.TIMER, moveRed);
timerBlue.addEventListener(TimerEvent.TIMER, moveBlue);

//current rotation angle position
var angle:Number=0;
var angleB:Number = 0;
var angleR:Number = 0;

//green circular function
function moveCircle (e:TimerEvent):void {
	btnGreenBig.x = btnGreenBig.x + (Math.cos(angle) * distance);
	btnGreenBig.y = btnGreenBig.y + (Math.sin(angle) * distance)
	angle += 0.1;
}

//red circular function
function moveRed (e:TimerEvent):void {
	btnRedBig.x = btnRedBig.x + Math.cos(angleR) * distance;
	btnRedBig.y = btnRedBig.y + Math.sin(angleR) * distance;
	angleR += 0.1;
}

//blue circular function
function moveBlue(e:TimerEvent):void {
	btnBlueBig.x = btnBlueBig.x + Math.cos(angleB) * distance;
	btnBlueBig.y = btnBlueBig.y + Math.sin(angleB) * distance;
	angleB += 0.1;
}

//start timer/circular anim on the provided movieclip.
function startTimer(it:MovieClip):void {
	if(it==btnGreenBig) time.start();
	if(it==btnRedBig) timerRed.start();
	if(it==btnBlueBig) timerBlue.start();
}
//stop timer/circular anim
function stopTimer(it:MovieClip):void {
	if(it==btnGreenBig) time.stop();
	if(it==btnRedBig) timerRed.stop();
	if(it==btnBlueBig) timerBlue.stop();
}

 

E este é o que eu adiconei o mais 1 botão o Violet e tambem dupliquei os movieclipe e alterei os nomes

 

loadButtons(); //load the listeners

function loadButtons():void {
	btnGreenBig.buttonBackGreen.useHandCursor=true;
	btnGreenBig.buttonBackGreen.buttonMode=true;
	
	btnRedBig.buttonBackRed.useHandCursor=true;
	btnRedBig.buttonBackRed.buttonMode=true;
	
	btnBlueBig.buttonBackBlue.useHandCursor=true;
	btnBlueBig.buttonBackBlue.buttonMode=true;
	
	btnBlueBig.buttonBackViolet.useHandCursor=true;
	btnBlueBig.buttonBackViolet.buttonMode=true;
	
	btnGreenBig.buttonBackGreen.addEventListener(MouseEvent.MOUSE_OVER, onmouseover);
	btnGreenBig.buttonBackGreen.addEventListener(MouseEvent.MOUSE_OUT, onmouseout);
	btnGreenBig.buttonBackGreen.addEventListener(MouseEvent.CLICK, onMouseClick);
	
	btnBlueBig.buttonBackBlue.addEventListener(MouseEvent.MOUSE_OVER, onmouseover);
	btnBlueBig.buttonBackBlue.addEventListener(MouseEvent.MOUSE_OUT, onmouseout);
	btnBlueBig.buttonBackBlue.addEventListener(MouseEvent.CLICK, onMouseClick);
	
	btnRedBig.buttonBackRed.addEventListener(MouseEvent.MOUSE_OVER, onmouseover);
	btnRedBig.buttonBackRed.addEventListener(MouseEvent.MOUSE_OUT, onmouseout);
	btnRedBig.buttonBackRed.addEventListener(MouseEvent.CLICK, onMouseClick);
	
	btnRedBig.buttonBackViolet.addEventListener(MouseEvent.MOUSE_OVER, onmouseover);
	btnRedBig.buttonBackViolet.addEventListener(MouseEvent.MOUSE_OUT, onmouseout);
	btnRedBig.buttonBackViolet.addEventListener(MouseEvent.CLICK, onMouseClick);
}

//the glow filters to apply the swirl
var glR:GlowFilter = new GlowFilter(0xcc0000,1,50,50,2.5);
var glG:GlowFilter = new GlowFilter(0x91e600,1,50,50,2);
var glB:GlowFilter = new GlowFilter(0x0033ff,1,50,50,3.5);
var glV:GlowFilter = new GlowFilter(0x0033ff,1,50,50,3);

//mouse over handler
function onmouseover(evt:MouseEvent):void {
	switch(evt.currentTarget.name) { //this is one way to find if the mouseOver is dispatched from the buttonBack MC
		case "buttonBackGreen":
			btnGreenBig.homeOverSwirl.gotoAndPlay(2); //animate the swirl grow
			btnGreenBig.homeLabel.gotoAndStop(2); //put the label on white
			btnGreenBig.homeOverSwirl.filters=[glG]; //applay filters to the swirl
			Mstatus.text="mouseOver Home!"; //update button status text
			startTimer(btnGreenBig); //start the timer to animate the cricular move of button
		break;
		case "buttonBackBlue": //same as on the green button
			btnBlueBig.contactOverSwirl.gotoAndPlay(2);
			btnBlueBig.contactLabel.gotoAndStop(2);
			btnBlueBig.contactOverSwirl.filters=[glB];
			Mstatus.text="mouseOver Contact!";
			startTimer(btnBlueBig);
		break;
		case "buttonBackRed": //same as on the green button
			btnRedBig.aboutOverSwirl.gotoAndPlay(2);
			btnRedBig.aboutLabel.gotoAndStop(2);
			btnRedBig.aboutOverSwirl.filters=[glR];
			Mstatus.text="mouseOver About!";
			startTimer(btnRedBig);
		break;
		case "buttonBackViolet": //same as on the green button
			btnVioletBig.testeOverSwirl.gotoAndPlay(2);
			btnVioletBig.testeLabel.gotoAndStop(2);
			btnVioletBig.testeOverSwirl.filters=[glV];
			Mstatus.text="mouseOver Teste!";
			startTimer(btnVioletBig);
		break;
	}	
}

//mouse out handler
function onmouseout(evt:MouseEvent):void {
	switch(evt.target) { //this is another way to check if the event is dispatched from buttonBack MC
		case btnGreenBig.buttonBackGreen:
			btnGreenBig.homeOverSwirl.gotoAndPlay("fade"); //play the fade effect
			btnGreenBig.homeLabel.gotoAndStop(1); //return label to his original color
			Mstatus.text="mouseOut Home!"; //update status text
			stopTimer(btnGreenBig); //stop the circular move
		break;
		case btnBlueBig.buttonBackBlue: //sabe as green button
			btnBlueBig.contactOverSwirl.gotoAndPlay("fade");
			btnBlueBig.contactLabel.gotoAndStop(1);
			Mstatus.text="mouseOut Contact!";
			stopTimer(btnBlueBig);
		break;
		case btnRedBig.buttonBackRed: //sabe as green button		
			btnRedBig.aboutOverSwirl.gotoAndPlay("fade");
			btnRedBig.aboutLabel.gotoAndStop(1);
			stopTimer(btnRedBig);
			Mstatus.text="mouseOut About!";
		break;
		case btnVioletBig.buttonBackViolet:
			btnVioletBig.testeOverSwirl.gotoAndPlay("fade"); //play the fade effect
			btnVioletBig.testeLabel.gotoAndStop(1); //return label to his original color
			Mstatus.text="mouseOut Teste!"; //update status text
			stopTimer(btnVioletBig); //stop the circular move
		break;
	}
}

//click handler
function onMouseClick(evt:MouseEvent):void {
	switch(evt.currentTarget.name) {
		case "buttonBackGreen":
			Mstatus.text="mouseClick Home!";
		break;
		case "buttonBackBlue":	
			Mstatus.text="mouseClick Contact!";
		break;
		case "buttonBackRed":
			Mstatus.text="mouseClick About!";
		break;
	case "buttonBackViolet":
			Mstatus.text="mouseClick Teste!";
		break;
	}
}


/***circular animation ***/
var distance:Number = 0.4; //circular distance
var speed:Number=20; //more hight, less speed

//button timers to do the circular move
var time:Timer = new Timer(speed); //green one
var timerBlue:Timer = new Timer(speed); //blue
var timerRed:Timer = new Timer(speed); //red
var timerViolet:Timer = new Timer(speed); //red
//listeners to update button position
time.addEventListener(TimerEvent.TIMER, moveCircle);
timerRed.addEventListener(TimerEvent.TIMER, moveRed);
timerBlue.addEventListener(TimerEvent.TIMER, moveBlue);
timerViolet.addEventListener(TimerEvent.TIMER, moveViolet);

//current rotation angle position
var angle:Number=0;
var angleB:Number = 0;
var angleR:Number = 0;
var angleV:Number = 0;

//green circular function
function moveCircle (e:TimerEvent):void {
	btnGreenBig.x = btnGreenBig.x + (Math.cos(angle) * distance);
	btnGreenBig.y = btnGreenBig.y + (Math.sin(angle) * distance)
	angle += 0.1;
}

//red circular function
function moveRed (e:TimerEvent):void {
	btnRedBig.x = btnRedBig.x + Math.cos(angleR) * distance;
	btnRedBig.y = btnRedBig.y + Math.sin(angleR) * distance;
	angleR += 0.1;
}

//blue circular function
function moveBlue(e:TimerEvent):void {
	btnBlueBig.x = btnBlueBig.x + Math.cos(angleB) * distance;
	btnBlueBig.y = btnBlueBig.y + Math.sin(angleB) * distance;
	angleB += 0.1;
}

//Violet circular function
function moveViolet(e:TimerEvent):void {
	btnVioletBig.x = btnVioletBig.x + Math.cos(angleV) * distance;
	btnVioletBig.y = btnVioletBig.y + Math.sin(angleV) * distance;
	angleV += 0.1;
}

//start timer/circular anim on the provided movieclip.
function startTimer(it:MovieClip):void {
	if(it==btnGreenBig) time.start();
	if(it==btnRedBig) timerRed.start();
	if(it==btnBlueBig) timerBlue.start();
	if(it==btnVioletBig) timerViolet.start();
}
//stop timer/circular anim
function stopTimer(it:MovieClip):void {
	if(it==btnGreenBig) time.stop();
	if(it==btnRedBig) timerRed.stop();
	if(it==btnBlueBig) timerBlue.stop();
	if(it==btnVioletBig) timerViolet.stop();
}

 

 

e este é o link com 4 botões que não funciona o efeito

 

http://www.hollysand...com.br/menu.rar

 

este é le funcinando com três

 

http:www.hollysandallias.com.br/menu.html

Compartilhar este post


Link para o post
Compartilhar em outros sites

você baixou o arquivo que coloquei e o viu funcionando?

 

você pode ir tentando alterar o q for preciso no q está funcionando (sempre testando pra identificar se errar) ou é só comparar o que está funcionando com o que está dando erro...

 

a dica pra caso o erro não seja identificado, e você n tenha ideia do que seja, é comentar blocos de código, e ir descomentando até o erro aparecer.

 

ah, e sempre q der usa a tag code do forum, sinceramente acho que ninguém para pra ler um código assim sem color hint e identação, colocado direto no post.

Compartilhar este post


Link para o post
Compartilhar em outros sites

enfim... me baseei no código da Elektra, que já tinha uma boa parte do que precisava.

loadButtons(); //load the listeners

 

Oi Michel, o código é do Fecareis, eu apenas adicionei o 4º botão e uma linha extra de metida mesmo.

Como disse, não domino o action.

Publiquei para que o Jerfs pudesse visualizar.

Legal que você soube como resolver.

 

Abraços.

Compartilhar este post


Link para o post
Compartilhar em outros sites

×

Informação importante

Ao usar o fórum, você concorda com nossos Termos e condições.