import mx.transitions.Tween;
import mx.transitions.easing.*;
//create function to add buttons on stage
function addButtons() {
pushOverX = 0;
for (i=0; i<obj.buttons.length; i++) {
btn = menu.attachMovie("button", "btn"+i, -i, {_x:pushOverX, id:i});
btn.t.autoSize = "left";
btn.t.text = obj.buttons[i].attributes.title;
btn.t.textColor = tC;
btn.back._width = btn.t._width;
pushOverX += Math.round(btn._width+bS);
setBtnEvents(btn);
}
selectFirstBtn();
var cl:Color = new Color(menu.bar);
cl.setRGB(tROC);
}
//create function for buttons events
function setBtnEvents(btn:MovieClip) {
btn.onRollOver = function() {
btn = this;
st = obj.buttons[btn.id].attributes.title;
//apply effect to this btn
btn.t.textColor = tROC;
typeText(btn.t,st,0,5);
//stop current tween
menu.bar.tweenX.stop();
menu.bar.tweenWidth.stop();
//tween bar
menu.bar.tweenX = new Tween(menu.bar, "_x", Strong.easeOut, menu.bar._x, btn._x, .6, true);
menu.bar.tweenWidth = new Tween(menu.bar, "_width", Strong.easeOut, menu.bar._width, btn.back._width, .6, true);
//apply effect to pressed btn
pressedBtn.t.textColor = tC;
typeText(pressedBtn.t,obj.buttons[pressedBtn.id].attributes.title,0,1);
//play sound
s.start();
};
btn.onRollOut = function() {
btn = this;
st = obj.buttons[btn.id].attributes.title;
//apply effect to this btn
btn.t.textColor = tC;
typeText(btn.t,st,0,1);
//stop current tween
menu.bar.tweenX.stop();
menu.bar.tweenWidth.stop();
//tween bar
menu.bar.tweenX = new Tween(menu.bar, "_x", Strong.easeOut, menu.bar._x, pressedBtn._x, .6, true);
menu.bar.tweenWidth = new Tween(menu.bar, "_width", Strong.easeOut, menu.bar._width, pressedBtn.back._width, .6, true);
//apply effect to pressed btn
pressedBtn.t.textColor = tROC;
typeText(pressedBtn.t,obj.buttons[pressedBtn.id].attributes.title,0,5);
//play sound
s.start();
};
btn.onPress = function() {
pressedBtn.enabled = true;
pressedBtn = this;
this.enabled = false;
//ADD HERE CUSTOM FUNCTION
st = obj.buttons[pressedBtn.id].attributes.title + " button is pressed";
demoFunction(st);
};
}
function selectFirstBtn(){
pressedBtn = menu.btn0;
pressedBtn.enabled = false;
//tween bar
menu.bar.tweenX = new Tween(menu.bar, "_x", Strong.easeOut, menu.bar._x, pressedBtn._x, .6, true);
menu.bar.tweenWidth = new Tween(menu.bar, "_width", Strong.easeOut, menu.bar._width, pressedBtn.back._width, .6, true);
//apply effect to this btn
pressedBtn.t.textColor = tROC;
typeText(pressedBtn.t,obj.buttons[pressedBtn.id].attributes.title,0,5);
}
//create typing effect
function typeText(t:TextField, finalString:String, initRandomStringLength:Number, speed:Number) {
var currentLength:Number = 0;
var counter:Number = 0;
t._parent.onEnterFrame = function() {
if (currentLength<finalString.length) {
counter++;
var currentString:String = "";
var randString:String = "";
//get random char
for (i=currentLength; i<initRandomStringLength; i++) {
randString += String.fromCharCode(random(50)+20);
}
//add char to complete string
for (i=0; i<=currentLength; i++) {
currentString += finalString.charAt(i);
}
//if counter is equal to speed or the correct char is found add one unit to current length and set counter equal to 0
if (counter>=speed || randString.charAt(stL) == finalString.charAt(stL)) {
currentLength++;
counter = 0;
}
if (initRandomStringLength<finalString.length-1) {
initRandomStringLength++;
}
t.text = currentString+randString;
} else {
delete t._parent.onEnterFrame;
}
};
}
//this function is for preview
function demoFunction(st:String){
demoMC._alpha = 100;
demoMC.t.text = st;
demoMC.t.textColor = tROC;
demoMC.tweenAlpha = new Tween(demoMC, "_alpha", Strong.easeIn, 100, 0, 1, true);
}
//create sound object to load the rollover sound (you can change the path for another sound)
var s:Sound = new Sound();
s.loadSound("rollOverSound.mp3");
s.setVolume(80);
var tC:Number = new Number();//text color
var tROC:Number = new Number();//rollover text color
var bS:Number = new Number();//buttons spacing
var pressedBtn:MovieClip = new MovieClip();
//object that contains data from xml
var obj:Object = new Object();
//create nex xml object
var xml:XML = new XML();
xml.ignoreWhite = true;
//after the xml is loaded, load variables and parse the date to obj
xml.onLoad = function(succes) {
if (succes) {
tC = Number(this.firstChild.attributes.textColor);
tROC = Number(this.firstChild.attributes.rolloverColor);
bS = Number(this.firstChild.attributes.spacing);
obj.buttons = this.firstChild.childNodes;
//function call
addButtons();
} else {
trace("xml could not load");
}
};
//the path to the xml file
xml.load("menu.xml");
urlMC.onPress = function(){
getURL ("http://www.nogrids.com", "_blank");
}
-
Obrigado
Editado por Jonathan Queiroz Remover caixa alta do título (Jonathan)
Pergunta
gmbotega
LINK PARA ARQUIVO : www.linceuftm.com/menu/menu.rar > clica aqui
Bom pessoal, espero que me ajudem:
o que eu preciso é INSERIR um link ( href ) no menu.
o arquivo . fla está em anexo
o xml é o seguinte :
CODIGO DO .FLA-
Obrigado
Editado por Jonathan QueirozRemover caixa alta do título (Jonathan)
Link para o comentário
Compartilhar em outros sites
0 respostass a esta questão
Posts Recomendados
Participe da discussão
Você pode postar agora e se registrar depois. Se você já tem uma conta, acesse agora para postar com sua conta.