I’m trying to run a function, in AS2 , when after a specific amount of time of the mouse being idle a movieclip plays. Then when the mouse becomes active again a different movieclip plays. I have gotten my code work for the most part, but the last function runs over and over as the mouse is moving. I want it to run once, so the movieclip plays once.
here is my code:
standstill = 0; lastmove = 0; timeout = 3000;
this.onMouseUp = function(){ lastmove = getTimer(); idle(timeout); }; this.onMouseMove = function(){ lastmove = getTimer(); idle(timeout); };
aListener = new Object(); aListener.onKeyUp = function () { lastmove = getTimer(); idle(timeout);}; Key.addListener(aListener);
function idle(time){ this.onEnterFrame = function(){ standstill = getTimer()- lastmove; trace(standstill); DogSleep.gotoAndPlay(2); if(standstill >= time){ trace(“dog is sleeping”); this.onEnterFrame = null; standstill = 0;
this.onMouseMove = function(){ DogSleep.gotoAndPlay(300); } } } }
how do I do this? any help is appreciated. Thanks!
