flash actionscript:
not sure why you are using setInterval to do this. Try this... tabSpeed = 10 nav_mc.onEnterFrame = function() { if (nav_mc._x <= 50) { nav_mc._x += tabSpeed } };
I am trying to have a tab slide out onRollOver then slide back onRollOff. Currently I have got it to move to my target location but without the transition. Here is my attempt attachMovie("nav", "nav_mc", this.getNextHighestDepth(), {_x:0, _y:100}); var i=0; nav_mc.onRollOver = function():Void { while(i<=50) { nav_mc._x = i++; updateAfterEvent(); } }; moveMenu = setInterval(nav_mc.onRollOver,5);
here's how I might go about it. some problems with your code: putting the movement inside your rollover handler confuses things. it can be done, but really you want your movement to be triggered by the rollover, which means the way you have it set up you would need your setinterval inside your onRollover, which is the function your setinterval is calling, making for a recursive headache. also, you set up your movement in a while loop of one interval, when really you want your tab to move a step at a time over several intervals. change your 'while' to an 'if' to see what i mean. //constants NavIn=0 NavOut=50; navSpeed=1; //attach tab attachMovie("nav", "nav_mc", this.getNextHighestDepth(), {_x:In, _y:100}); //vars //navDirection 0=stationary, 1=animate out, -1=animate in nav_mc.navDirection=0; moveMenu = setInterval(MoveNav, 5, nav_mc); nav_mc.onRollOver = function():Void { this.navDirection=1; }; nav_mc.onRollOut = function():Void { this.navDirection=-1; }; function MoveNav(whichMC) { whichMC._x += whichMC.navDirection*navSpeed; if (whichMC._x>=NavOut) { whichMC._x=NavOut; whichMC.navDirection=0; } if (whichMC._x<=NavIn) { whichMC._x=NavIn; whichMC.navDirection=0; } }
Don't see what you're looking for? Try a search.
|