Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

setInterval curses me!!!!!!!!

Status
Not open for further replies.

digitalMercenary

Technical User
Feb 8, 2008
4
US
On my homepage, in the bottom right corner, there is a photo of myself. I coded a "widget" from it that animates its movement on the x-axis to reveal miscellaneous comments about myself. I did this using setInterval. When the user performs a rollOver, the movieClip containing my photo moves from point "A" to point "B" on the x-axis. When the user performs a rollout, it moves back from point "B" to point "A". This all works well and good until I wildly rollOver and rollOut.....the clip gets stuck in between at an odd point, and I have to rollOver it and rollOut slowly in order to reset the scale of the movieClip. There's always that person out there that likes to play with things to see if they mess up.....MINE MESSES UP!!!!!!! Someone point me in the right direction to correct this problem PLEASE!!!!!!!! Check out my url to see what I mean......
 
Oh..........but of course I'm clearing the interval.....
I added the .enabled property to prevent the radical behavior.....But, it still doesn't flow the way I want it.....Try it yourself. Create a movieClip called meThumb, and a movieClip called myThumb. Create a small box inside of meThumb. Then, drag an instance of meThumb onto the stage of myThumb. Experiment with the lines of code that say meThumb.enabled and myThumb.enabled both active and commented out. You'll see what I mean. I'm at wits end!!!!!!!

//var mtMove:Number = 0;
myThumb.onRollOver = function () {
function mtFwd() {
myThumb.meThumb._x += 6.5;
//mtMove++;
myThumb.enabled = false;
if(myThumb.meThumb._x >= 160) {
clearInterval(mtf);
myThumb.enabled = true;
//mtBck();
}
}
var mtf:Number = setInterval(mtFwd, 10);
updateAfterEvent();
}

//var mtMove:Number = 0;
myThumb.onRollOut = function () {
function mtBck() {
myThumb.meThumb._x -= 6.5;
myThumb.enabled = false;
//mtMove++;
if(myThumb.meThumb._x <= 0) {
myThumb.enabled = true;
clearInterval(mtb);
//mtBck();
}
}
var mtb:Number = setInterval(mtBck, 10);
updateAfterEvent();
}
 
Holy Crap. You couldn't be more right oldnewbie! I'm going to try that out this evening. I never, in a million years would have considered that. Thanks! I'll let you know how it goes.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top