I’m still quite a beginner at action script even though I’ve been using it for quite a while. Just can’t get a grip on it :/. Thinking of buying a book.
Anyhow. I made this menu which slides new menus depending on which button you pressed. Then when you press another button the one that is currently displayed slides back and the new one comes out. I set up the script so that a couple of variables say which menu is currently out.
I also did not want to nest my menu items further so I choose to set up a tween for each button. Which results in quite a lot of tweens.
Heres the scirpt:
[AS]outspeed = 20;
inspeed = 12;
omhundvar = 0;
kurservar = 0;
ovrigtvar = 0;
_root.omhund.onRelease = function() {
if (kurservar == 1) {
myTween = new mx.transitions.Tween(_root.flyin.kursp, “_x”, mx.transitions.easing.Back.easeInOut, _root.flyin.kursp._x, -300, outspeed);
myTween = new mx.transitions.Tween(_root.flyin.kursu, “_x”, mx.transitions.easing.Back.easeInOut, _root.flyin.kursu._x, -300, outspeed);
myTween = new mx.transitions.Tween(_root.flyin.rally, “_x”, mx.transitions.easing.Back.easeInOut, _root.flyin.rally._x, -300, outspeed);
myTween = new mx.transitions.Tween(_root.flyin.teamh, “_x”, mx.transitions.easing.Back.easeInOut, _root.flyin.teamh._x, -300, outspeed);
//trace(“k is in”);
kurservar = 0;
}
if (ovrigtvar == 1) {
myTween = new mx.transitions.Tween(_root.flyin.privat, “_x”, mx.transitions.easing.Back.easeInOut, _root.flyin.privat._x, -300, outspeed);
myTween = new mx.transitions.Tween(_root.flyin.hyr, “_x”, mx.transitions.easing.Back.easeInOut, _root.flyin.hyr._x, -300, outspeed);
myTween = new mx.transitions.Tween(_root.flyin.fore, “_x”, mx.transitions.easing.Back.easeInOut, _root.flyin.fore._x, -300, outspeed);
//trace(“o is in”);
ovrigtvar = 0;
}
myTween = new mx.transitions.Tween(_root.flyin.omhund, “_x”, mx.transitions.easing.Back.easeOut, -200, 0, inspeed);
myTween = new mx.transitions.Tween(_root.flyin.vipa, “_x”, mx.transitions.easing.Back.easeOut, -200, 0, inspeed);
myTween = new mx.transitions.Tween(_root.flyin.tankar, “_x”, mx.transitions.easing.Back.easeOut, -200, 0, inspeed);
myTween = new mx.transitions.Tween(_root.flyin.manad, “_x”, mx.transitions.easing.Back.easeOut, -200, 0, inspeed);
myTween = new mx.transitions.Tween(_root.flyin.nyhet, “_x”, mx.transitions.easing.Back.easeOut, -200, 0, inspeed);
omhundvar = 1;
};
_root.kurser.onRelease = function() {
if (omhundvar == 1) {
myTween = new mx.transitions.Tween(_root.flyin.omhund, “_x”, mx.transitions.easing.Back.easeInOut, _root.flyin.omhund._x, -300, outspeed);
myTween = new mx.transitions.Tween(_root.flyin.vipa, “_x”, mx.transitions.easing.Back.easeInOut, _root.flyin.vipa._x, -300, outspeed);
myTween = new mx.transitions.Tween(_root.flyin.tankar, “_x”, mx.transitions.easing.Back.easeInOut, _root.flyin.tankar._x, -300, outspeed);
myTween = new mx.transitions.Tween(_root.flyin.manad, “_x”, mx.transitions.easing.Back.easeInOut, _root.flyin.manad._x, -300, outspeed);
myTween = new mx.transitions.Tween(_root.flyin.nyhet, “_x”, mx.transitions.easing.Back.easeInOut, _root.flyin.nyhet._x, -300, outspeed);
//trace(“hund is in”);
omhundvar = 0;
}
if (ovrigtvar == 1) {
myTween = new mx.transitions.Tween(_root.flyin.privat, “_x”, mx.transitions.easing.Back.easeInOut, _root.flyin.privat._x, -300, outspeed);
myTween = new mx.transitions.Tween(_root.flyin.hyr, “_x”, mx.transitions.easing.Back.easeInOut, _root.flyin.hyr._x, -300, outspeed);
myTween = new mx.transitions.Tween(_root.flyin.fore, “_x”, mx.transitions.easing.Back.easeInOut, _root.flyin.fore._x, -300, outspeed);
//trace(“o is in”);
ovrigtvar = 0;
}
myTween = new mx.transitions.Tween(_root.flyin.kursp, “_x”, mx.transitions.easing.Back.easeOut, -200, 0, inspeed);
myTween = new mx.transitions.Tween(_root.flyin.kursu, “_x”, mx.transitions.easing.Back.easeOut, -200, 0, inspeed);
myTween = new mx.transitions.Tween(_root.flyin.rally, “_x”, mx.transitions.easing.Back.easeOut, -200, 0, inspeed);
myTween = new mx.transitions.Tween(_root.flyin.teamh, “_x”, mx.transitions.easing.Back.easeOut, -200, 0, inspeed);
kurservar = 1;
};
_root.ovrigt.onRelease = function() {
if (omhundvar == 1) {
myTween = new mx.transitions.Tween(_root.flyin.omhund, “_x”, mx.transitions.easing.Back.easeInOut, _root.flyin.omhund._x, -300, outspeed);
myTween = new mx.transitions.Tween(_root.flyin.vipa, “_x”, mx.transitions.easing.Back.easeInOut, _root.flyin.vipa._x, -300, outspeed);
myTween = new mx.transitions.Tween(_root.flyin.tankar, “_x”, mx.transitions.easing.Back.easeInOut, _root.flyin.tankar._x, -300, outspeed);
myTween = new mx.transitions.Tween(_root.flyin.manad, “_x”, mx.transitions.easing.Back.easeInOut, _root.flyin.manad._x, -300, outspeed);
myTween = new mx.transitions.Tween(_root.flyin.nyhet, “_x”, mx.transitions.easing.Back.easeInOut, _root.flyin.nyhet._x, -300, outspeed);
//trace(“hund is in”);
omhundvar = 0;
}
if (kurservar == 1) {
myTween = new mx.transitions.Tween(_root.flyin.kursp, “_x”, mx.transitions.easing.Back.easeInOut, _root.flyin.kursp._x, -300, outspeed);
myTween = new mx.transitions.Tween(_root.flyin.kursu, “_x”, mx.transitions.easing.Back.easeInOut, _root.flyin.kursu._x, -300, outspeed);
myTween = new mx.transitions.Tween(_root.flyin.rally, “_x”, mx.transitions.easing.Back.easeInOut, _root.flyin.rally._x, -300, outspeed);
myTween = new mx.transitions.Tween(_root.flyin.teamh, “_x”, mx.transitions.easing.Back.easeInOut, _root.flyin.teamh._x, -300, outspeed);
//trace(“k is in”);
kurservar = 0;
}
myTween = new mx.transitions.Tween(_root.flyin.privat, “_x”, mx.transitions.easing.Back.easeOut, -200, 0, inspeed);
myTween = new mx.transitions.Tween(_root.flyin.hyr, “_x”, mx.transitions.easing.Back.easeOut, -200, 0, inspeed);
myTween = new mx.transitions.Tween(_root.flyin.fore, “_x”, mx.transitions.easing.Back.easeOut, -200, 0, inspeed);
ovrigtvar = 1;
};[/AS]
Anything I could do to optimize this would be really helpfull.
Thanks!