PDA

View Full Version : setInterval not working


Shaded
03-22-2003, 07:54 PM
Hello,

I am experiencing a strange problem with regards to "setInterval" not starting if "getSelectedIndex" has been called on a listBox.

I am using setInterval to fade in content loaded with loadMovie. All works well until "getSelectedIndex" is called - at that point, setInterval refuses to start doing its thing.

Any help or experience would be much appreciated.

bluegel
03-22-2003, 07:57 PM
can you put up a little code, cos it might just be something in your code thats not 100% correct.

thanx

Shaded
03-22-2003, 08:09 PM
Sure,

Here is the code on Frame 1:

function fadeInContent(){
contentFadeAmount = 0;
fadeIn = setInterval(fade, 50);
contentMovieClip._alpha = 100;
}

function fade() {
contentMovieClip._alpha = contentFadeAmount;
contentFadeAmount = _global.contentFadeAmount+10;
if (_global.contentFadeAmount>=100) {
clearInterval(fadeIn);
}
}

And here is the button code affecting the (totally unrelated) listBox called myInfo which causes the above setInterval to not be called.

on(release)
{
listitem = _root.myInfo.getSelectedIndex();
_root.myInfo.removeItemAt(listitem);
}

Thanks for any help!

boyzdynasty
03-22-2003, 08:21 PM
// This function you call to setInterval...*looks fine*

function fadeInContent(){
contentFadeAmount = 0;
fadeIn = setInterval(fade, 50);
contentMovieClip._alpha = 100;
}

// This function is what is called by setInterval....
// I see you want to clear Interval when contentFadeAmount >= 100
// But are you refering to the same variable in "fadeInContent"?
// If you are, you don't need to make in global and you need a
// a counter of some sort .... b/c contentFadeAmount seems to be
// only at 0.
// If it only stays at zero, your condition will never be true to clearInterval.

function fade() {
contentMovieClip._alpha = contentFadeAmount;
contentFadeAmount = _global.contentFadeAmount+10;
if (_global.contentFadeAmount>=100) {
clearInterval(fadeIn);
}
}

boyzdynasty
03-22-2003, 08:29 PM
as for...

And here is the button code affecting the (totally unrelated) listBox called myInfo which causes the above setInterval to not be called.

on(release)
{
listitem = _root.myInfo.getSelectedIndex();
_root.myInfo.removeItemAt(listitem);
}
I'm not sure why you have this for.... I gotta fly....hopefully someone else can be of great help to you.

Well...I'll check the thread out later tonight *just in case*

Shaded
03-22-2003, 08:33 PM
Thanks so much for your help!

The Global variable designation were left over from part of an experiment. This part of the code works fine.

The trouble is after the button is pressed to remove an item from a list box - the setInterval then refuses to be called.

Thanks again.

bluegel
03-23-2003, 02:06 PM
thanx boyz - was being a bit tired today, and not very with it - as mentioned in PM

and shaded:

The trouble is after the button is pressed to remove an item from a list box - the setInterval then refuses to be called.

put some traces in, to see where the problem starts, and if you still can't suss out what the problem is, post the code, where the problem begins - or even, upload your file.

Shaded
03-23-2003, 03:05 PM
Thanks so much bluegel! I have attached a .zip of the FLA files - the item in question is called insideMM.fla.

bluegel
03-24-2003, 10:24 AM
file??

senocular
03-25-2003, 01:40 AM
this might help
http://www.umbc.edu/interactive/flash/tutorials/setInterval.php

boyzdynasty
03-25-2003, 02:52 AM
Originally posted by bluegel
file?? yup yup...no file was attach :(