hello
I am trying to make an horizontal scrollable menu.
Like on this site! http://www.endcommunications.com/
The menu follows the moves of the mouse
I have made the motion but i need to make it smoother. I need to add an easyOut to the menu when the mouse leaves the hot area.
Can you please help me ?
This is the code
Code:stageWidth = Stage.width; center = stageWidth / 2; speed = 8; onEnterFrame = function() { mouseSpeed = Math.abs(_xmouse - center ); if (_root._xmouse > center + 350) { tr = 1; if (Math.abs(mainBar._x) < mainBar._width - stageWidth) { mainBar._x = mainBar._x - (Math.abs(center - _xmouse)/500) * speed; } //trace(mainBar._x); } else if (_root._xmouse < 100) { tr = 5; if (mainBar._x < 0) { mainBar._x = mainBar._x + (Math.abs(_xmouse - center )/500) * speed; } } updateAfterEvent(); }
I tried this but it didn't work !
Thank youCode:stageWidth = Stage.width; center = stageWidth / 2; speed = 8; function easyStop(startpoint, endpoint) { import mx.transitions.Tween; import mx.transitions.easing.*; var xPosT:Tween = new Tween(mainBar, "_x", Regular.easeOut, startpoint, endpoint, 1, true); xPosT["onMotionFinished"] = function(){ tr = 0; trace('hello'); } } onEnterFrame = function() { mouseSpeed = Math.abs(_xmouse - center ); if (_root._xmouse > center + 350) { tr = 1; if (Math.abs(mainBar._x) < mainBar._width - stageWidth) { mainBar._x = mainBar._x - (Math.abs(center - _xmouse)/500) * speed; } //trace(mainBar._x); } else if (_root._xmouse < 100) { tr = 5; if (mainBar._x < 0) { mainBar._x = mainBar._x + (Math.abs(_xmouse - center )/500) * speed; } } trace('tr==='+tr); if (_root._xmouse > center && _root._xmouse < stageWidth - 351 && tr == 1) { easyStop(this._x, this._x+20); } updateAfterEvent(); }


Reply With Quote
Bookmarks