actionscript 3 - flash AS3 menu - next active button resets previous active button -
i have been working on problem 3 days , nights. have make website uni , have completed layout , content etc. menu complete, apart fact cannot make i'd do.
some appreciated, since complete novice @ as3 , don't know how solve problem.
here i'd happen:
- home button's state active when homepage active.
- when button hovered, animation button plays
- when new button clicked, animation of active button reversed (or set inactive) , new button remains active + new web page loaded
some details menu:
the animation (active image sliding in , out of view) , hyperlinking work fine, don't know how code other things.
it consists of background images buttons inactive state. contains invisible hit boxes each item in menu, because active image outside of visible menu-area (hidden behind main content area) active image slides view left, covering background area respective (inactive) button.
i hope made sense^^
here code far:
import fl.transitions.tween; import fl.transitions.easing.*; hit_home.addeventlistener(mouseevent.roll_over, overhome); hit_resume.addeventlistener(mouseevent.roll_over, overresume); home.addeventlistener(mouseevent.roll_over, overhome); home.addeventlistener(mouseevent.roll_out, outhome); home.addeventlistener(mouseevent.click, clickhome); home.addeventlistener(mouseevent.mouse_down, downhome); resume.addeventlistener(mouseevent.roll_over, overresume); resume.addeventlistener(mouseevent.roll_out, outresume); resume.addeventlistener(mouseevent.click, clickresume); resume.addeventlistener(mouseevent.mouse_down, downresume); hit_resume.buttonmode = hit_home.buttonmode = home.buttonmode = resume.buttonmode = true; hit_resume.usehandcursor = hit_home.usehandcursor = home.usehandcursor = resume.usehandcursor = true; //i trying save x-position of home button prior animation. //var home:int=x=0; //var home_original:int=home.x; // failed miserably. var animation:tween; // home button stuff function overhome (e:mouseevent):void { animation = new tween(home, "x", elastic.easeout, home.x, 124, 1, true); } function outhome (e:mouseevent):void { animation = new tween(home, "x", elastic.easeout, home.x, -124, 1, true); } function clickhome(e:mouseevent):void { navigatetourl(new urlrequest(""), ""); } function downhome(e:mouseevent):void{ home.gotoandstop(1); } //resume button stuff function overresume (e:mouseevent):void { animation = new tween(resume, "x", elastic.easeout, resume.x, 124, 1, true); } function outresume (e:mouseevent):void { animation = new tween(resume, "x", elastic.easeout, resume.x, -124, 1, true); } function clickresume(e:mouseevent):void { navigatetourl(new urlrequest(""), ""); } function downresume(e:mouseevent):void{ resume.gotoandstop(1); }
yes, script bloated , super nooby, that's manage.
any suggestions on how things done properly?
thanks upfront.
p.s.: if need see .swf file, let me know , provide link it.
edit:
i think managed fix now^^ maybe can me clean code it's not bloated anymore?
// import classes needed tweening import fl.transitions.tween; import fl.transitions.easing.*; hit_home.addeventlistener(mouseevent.click, clickhome); hit_resume.addeventlistener(mouseevent.click, clickresume); home.addeventlistener(mouseevent.click, clickhome); hit_home.addeventlistener(mouseevent.mouse_up, uphome); resume.addeventlistener(mouseevent.click, clickresume); hit_resume.addeventlistener(mouseevent.mouse_up, upresume); hit_resume.buttonmode = hit_home.buttonmode = home.buttonmode = resume.buttonmode = true; hit_resume.usehandcursor = hit_home.usehandcursor = home.usehandcursor = resume.usehandcursor = true; //i trying save x-position of home button prior animation. //var home:int=x=0; //var home_original:int=home.x; // failed miserably. var animation:tween; // home button stuff function clickhome (e:mouseevent):void { animation = new tween(home, "x", elastic.easeout, home.x, 124, 1, true); navigatetourl(new urlrequest(""), ""); } //function outhome (e:mouseevent):void // { // animation = new tween(home, "x", elastic.easeout, home.x, -124, 1, true); // } function uphome(e:mouseevent):void{ animation = new tween(resume, "x", elastic.easeout, resume.x, -124, 1, true); home.gotoandstop(1); } //resume button stuff function clickresume (e:mouseevent):void { animation = new tween(resume, "x", elastic.easeout, resume.x, 124, 1, true); navigatetourl(new urlrequest(""), ""); } //function outresume (e:mouseevent):void // { // animation = new tween(resume, "x", elastic.easeout, resume.x, -124, 1, true); // } function upresume(e:mouseevent):void{ animation = new tween(home, "x", elastic.easeout, home.x, -124, 1, true); resume.gotoandstop(1); }
Comments
Post a Comment